Assembla home | Assembla project page
 

Changeset 194

Show
Ignore:
Timestamp:
03/29/08 13:28:33 (8 months ago)
Author:
Slynderdale
Message:

A whole lot of enhancements and bug fixes. The files were also updated to use the new path constants.

Notable changes:

  • Acronyym: No longer requires Users, instead its optional for the randomnick feature.
  • ChuckNorris: Added a feature so reponses now have a random chanve at appearing and also added CTCP support.
  • Debug: Added a backwards compatibility check for PHP versions below 5.2
  • FeedTicker?: Added a dependency check for !SimpleXML
  • JoinPart: Allows for multiple channel joins and parts as well as part messages. Also added support for part all
  • Karma: Added some fixes, and also a Blacklist for entries that can't be changed or views. Also added support for ++word and --word
  • Lart: Added some bug fixes and also added support to make lart admin/op only with an ini setting.
  • Logging: Chnaged how other plugins can access the logging data by adding a static prepare function
  • Math: Minor fix to fix support for things like (#)(#) where no operator is defined, it now defaults to multiplication
  • ModuleList: Cleaned up the code a bit and added support for Inactive plugins as well Passive plugins
  • NickServ: Added auto ghosting support and nick name recovery. Also added a KILL handler for when the server sends a KILL request to Phergie. It now quits instead of timing out.
  • Puppet: Added the command raw (hostmask admins only) to send raw messages to the server
  • Sed: Greatly improved Sed to allow matching against specified previous lines as well as correcting other peoples lines. Also tweaked the Sed statement syntax a bit.
  • Seen: Added various bug fixes and took into account the changes in Logging
  • Tld: Now scrapes the data from http://www.iana.org/domains/root/db/ and also gathered the TLDs type as well.
  • Toggle: Added various tweaks and bug fixes
  • Url: Fixed URLs ending in a ; and also changed the old error handler to onPHPError
  • Users: Fixed a bug that caused the User's data to become corrupted. Also now all matches are done case insensitive.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Event/Request.php

    r167 r194  
    114114 
    115115        self::TYPE_PART => array( 
    116             'channel' => 0 
     116            'channel' => 0, 
     117            'message' => 1 
    117118        ), 
    118119 
  • trunk/Phergie/Plugin/Abstract/Cron.php

    r166 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Base.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    77 
    88/** 
  • trunk/Phergie/Plugin/Acronym.php

    r180 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Base.php'; 
    7  
    8 /** 
    9 * @see Phergie_Plugin_Users 
    10 */ 
    11 require_once 'Phergie/Plugin/Users.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    127 
    138/** 
     
    7974 
    8075    /** 
    81     * Returns whether or not the plugin's dependencies are met. 
    82     * 
    83     * @param Phergie_Driver_Abstract $client Client instance 
    84     * @param array $plugins List of short names for plugins that the 
    85     *                       bootstrap file intends to instantiate 
    86     * @see Phergie_Plugin_Abstract_Base::checkDependencies() 
    87     * @return bool TRUE if dependencies are met, FALSE otherwise 
    88     */ 
    89     public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
    90     { 
    91         if (! in_array('Users', $plugins) 
    92             || ! Phergie_Plugin_Users::checkDependencies($client, $plugins)) { 
    93             return false; 
    94         } 
    95  
    96         return true; 
    97     } 
    98  
    99     /** 
    10076    * Returns a random action, meant for cases where an acronym lookup 
    10177    * returns no results. 
     
    10783    { 
    10884        do { 
    109             $reaction = $this->reactions[rand(0, count($this->reactions) - 1)]; 
    110             $randomUser = strpos($reaction, '%randomuser%'); 
     85            $reaction = $this->reactions[mt_rand(0, count($this->reactions) - 1)]; 
     86            $randomUser = (strpos($reaction, '%randomuser%') !== false); 
    11187        } while ($target[0] != '#' && $randomUser); 
    11288        if ($randomUser) { 
    113             $nick = $this->getIni('nick'); 
    114             do { 
    115                 $user = Phergie_Plugin_Users::getRandomUser($target); 
    116             } while ($user == $nick); 
     89                if ($this->pluginLoaded('Users')) { 
     90                $nick = $this->getIni('nick'); 
     91                do { 
     92                    $user = Phergie_Plugin_Users::getRandomUser($target); 
     93                } while ($user == $nick); 
     94            } else { 
     95                $user = $this->event->getNick(); 
     96            } 
    11797            $reaction = str_replace('%randomuser%', $user, $reaction); 
    11898        } 
     
    128108    public function onPrivmsg() 
    129109    { 
    130         $target = $this->event->getSource(); 
     110        $source = $this->event->getSource(); 
    131111        $message = $this->event->getArgument(1); 
     112        $target = $this->event->getNick(); 
    132113        $today = date('md'); 
    133114 
     
    144125 
    145126        if (in_array($acronym, array('WHO', 'WHAT', 'WHERE', 'WHEN', 'WHY', 'HOW'))) { 
    146             $this->doAction($target, 'shrugs.'); 
     127            $this->doAction($source, 'shrugs.'); 
    147128            return; 
    148129        } 
     
    170151                || strpos($contents, 'no abbreviation matches') !== false 
    171152                || strpos($contents, 'has exceeded the daily query limit') !== false) { 
    172                 $this->randomAction($target); 
     153                $this->randomAction($source); 
    173154                return; 
    174155            } else { 
     
    200181 
    201182            $text = 'Possible matches for ' . $acronym . ': ' . implode('; ', $matches); 
    202             $this->doPrivmsg($target, $text); 
     183            $this->doPrivmsg($source, $target . ': ' . $text); 
    203184        } 
    204185    } 
  • trunk/Phergie/Plugin/Altnick.php

    r71 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Base.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    77 
    88/** 
     
    1212class Phergie_Plugin_Altnick extends Phergie_Plugin_Abstract_Base 
    1313{ 
     14        /** 
     15        * Determines if the plugin is a passive plugin or not 
     16        * 
     17        * @var bool 
     18        */ 
     19        public $passive = true; 
     20 
    1421    /** 
    1522    * Index of the last alternate nick that the bot attempted to use 
  • trunk/Phergie/Plugin/Autojoin.php

    r175 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Base.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    77 
    88/** 
     
    1515class Phergie_Plugin_Autojoin extends Phergie_Plugin_Abstract_Base 
    1616{ 
     17        /** 
     18        * Determines if the plugin is a passive plugin or not 
     19        * 
     20        * @var bool 
     21        */ 
     22        public $passive = true; 
     23 
    1724    /** 
    1825    * Returns whether or not the current environment meets the requirements 
  • trunk/Phergie/Plugin/ChuckNorris.php

    r179 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Command.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    77 
    88/** 
     
    1212* into a database for quick access. 
    1313*/ 
    14 class Phergie_Plugin_ChuckNorris extends Phergie_Plugin_Abstract_Command 
     14class Phergie_Plugin_ChuckNorris extends Phergie_Plugin_Abstract_Base 
    1515{ 
    1616 
     
    6363    * @var int 
    6464    */ 
    65     protected $floodCheck = 10; 
     65    protected $floodCheck = 30; 
     66 
     67    /** 
     68    * The chance of responding with a random Chuck Norris fact. The chance can 
     69    * bet set anywheres from 1 - 100 while a value like 50 is a 50% chance. 
     70    * Set to 0 or below or a value of 100 or higher to disable. 
     71    * 
     72    * @var int 
     73    */ 
     74    protected $chance = 50; 
    6675 
    6776    /** 
     
    8190            // Initialize the database connection 
    8291              $this->db = new PDO('sqlite:' . $this->dir . 'norris.db'); 
     92              if (!$this->db) { 
     93                  return; 
     94              } 
    8395 
    8496            // Populate the database if necessary 
     
    92104            } 
    93105        } catch (PDOException $e) { } 
     106 
     107        $this->chance = intval($this->chance); 
     108        $this->floodCheck = intval($this->floodCheck); 
    94109    } 
    95110 
     
    118133    */ 
    119134    private function getChuckNorris($doCrawl = true) { 
    120           // The current page to retrieve 
    121           $page = trim($this->factHost . $this->crawlPage); 
     135        // The current page to retrieve 
     136        $page = trim($this->factHost . $this->crawlPage); 
    122137 
    123138        $this->debug('Retrieving page '.$this->crawlNum.' => '.$this->crawlPage); 
    124139        $contents = @file_get_contents($page); 
    125140        if ($contents !== false) { 
    126                   $this->debug('Parsing page '.$this->crawlNum.' => '.$this->crawlPage); 
     141                $this->debug('Parsing page '.$this->crawlNum.' => '.$this->crawlPage); 
    127142            preg_match_all('#<li>\s*([^<]+)\s*(?:<br>\s*&nbsp;)?<\/li>#im', $contents, $matches); 
    128143 
     
    147162                foreach ($pages as $page => $url) { 
    148163                    if ($page > $this->crawlNum) { 
    149                           $this->crawlNum = $page; 
     164                        $this->crawlNum = $page; 
    150165                        $this->crawlPage = $url; 
    151166 
     
    171186    */ 
    172187    private function findChuckNorris() { 
     188        if (!$this->db) { 
     189                return false; 
     190        } 
     191 
    173192        // Checks to see if the chuckfacts table exists 
    174193        $table = $this->db 
     
    196215    */ 
    197216    private function feedChuckNorris() { 
     217          if (!$this->db) { 
     218                  return false; 
     219          } 
     220 
    198221          // Check to see if there are any facts to insert 
    199222          if (count($this->norrisFacts) > 0) { 
     
    223246    private function praiseChuckNorris() 
    224247    { 
     248        if (!$this->db) { 
     249                return; 
     250        } 
     251 
    225252        return $this->db 
    226253            ->query('SELECT facts FROM chuckfacts ORDER BY Random() LIMIT 1') 
     
    236263    public function onPrivmsg() 
    237264    { 
     265        if (!$this->db) { 
     266                return; 
     267        } 
     268 
    238269        $source = $this->event->getSource(); 
    239270        $message = $this->event->getArgument(1); 
     
    241272        // Check to see if the message includes the word Chuck Norris. If so, check to see if 
    242273        // it was a bot request by checking for Fact: at the begiining and also do a floodpro check 
    243         if (!preg_match('{^(?:' . $this->getIni('nick') . '\s*:?\s+)}i', $message, $m) && 
    244             preg_match('{(chuck\s+norris)}i', $message, $m) && 
    245             strtolower(substr($message, 0, 5)) != 'fact:' && 
    246             ($this->floodCheck <= 0 || ($this->floodCache[$source] < (time() - $this->floodCheck))))
     274        if (preg_match('{^('.preg_quote($this->getIni('nick')).'\s*:?\s+)?\s*(chuck\s+norris)}ix', $message, $m) && 
     275            strtolower(substr($message, 0, 5)) != 'fact:' && ($source[0] != '#' || 
     276            (!empty($m[1]) || $this->chance <= 0 || $this->chance >= 100 || mt_rand(1, 100) < $this->chance) && 
     277            ($this->floodCheck <= 0 || ($this->floodCache[$source] < (time() - $this->floodCheck)))))
    247278 
    248279            // Retrieves a random fact 
     
    250281                if (!empty($fact)) { 
    251282                 $this->doPrivmsg($source, 'Fact: '.$fact); 
    252                  $this->floodCache[$source] = time(); 
     283                 if ($source[0] == '#') { 
     284                     $this->floodCache[$source] = time(); 
     285                 } 
    253286                 unset($m, $fact); 
    254287            } 
    255288        } 
    256289    } 
     290 
     291    /** 
     292    * Parses incoming CTCP request for the word "Chuck Norris" and respond with 
     293    * a random Chuck Norris fact retrieved from the Chuck Norris fact page. 
     294    * 
     295    * @return void 
     296    */ 
     297    public function onCtcp() 
     298    { 
     299        $source = $this->event->getSource(); 
     300        $ctcp = $this->event->getArgument(1); 
     301 
     302        if (!$this->db) { 
     303                return; 
     304        } 
     305 
     306        if (preg_match('{chuck[\s_+-]*norris}ix', $ctcp, $m)) { 
     307            // Retrieves a random fact 
     308            $fact = $this->praiseChuckNorris(); 
     309                if (!empty($fact)) { 
     310                $this->doCtcpReply($source, 'CHUCKNORRIS', $fact); 
     311            } 
     312        } 
     313    } 
    257314} 
  • trunk/Phergie/Plugin/Convert.php

    r179 r194  
    44* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Command.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 
    77 
    88/** 
     
    1313{ 
    1414    /** 
     15    * Returns whether or not the plugin's dependencies are met. 
     16    * 
     17    * @param Phergie_Driver_Abstract $client Client instance 
     18    * @param array $plugins List of short names for plugins that the 
     19    *                       bootstrap file intends to instantiate 
     20    * @see Phergie_Plugin_Abstract_Base::checkDependencies() 
     21    * @return bool TRUE if dependencies are met, FALSE otherwise 
     22    */ 
     23    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     24    { 
     25        if (!extension_loaded('Dom')) { 
     26            return false; 
     27        } 
     28 
     29        return true; 
     30    } 
     31 
     32    /** 
    1533    * Performs a unit conversion and returns the result in a message. 
    1634    * 
     
    2038    public function onDoConvert($convert) 
    2139    { 
     40        $target = $this->event->getNick(); 
     41 
    2242        $context = stream_context_create(array('http' => array( 
    2343            'timeout' => 5, 
     
    3858        $text = $result->item(0)->nodeValue; 
    3959 
    40         $this->doPrivmsg($this->event->getSource(), $text); 
     60        $this->doPrivmsg($this->event->getSource(), $target . ': ' . $text); 
    4161    } 
    4262} 
  • trunk/Phergie/Plugin/Ctcp.php

    r166 r194  
    11<?php 
    22 
    3 require_once 'Phergie/Plugin/Abstract/Base.php'; 
     3require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    44 
    55/** 
     
    88class Phergie_Plugin_Ctcp extends Phergie_Plugin_Abstract_Base 
    99{ 
     10        /** 
     11        * Determines if the plugin is a passive plugin or not 
     12        * 
     13        * @var bool 
     14        */ 
     15        public $passive = true; 
     16 
    1017    public function onTime() 
    1118    { 
     
    4148        $ctcp = strtoupper($this->event->getArgument(1)); 
    4249 
     50       // Uncaught PING requests 
     51       if ($ctcp == 'PING') 
     52           $this->doCtcpReply($source, 'pong'); 
    4353        // SOURCE Request, reply with the path to Phergie's SVN 
    44         if ($ctcp == 'SOURCE') 
     54        else if ($ctcp == 'SOURCE') 
    4555        { 
    4656            $this->doCtcpReply($source, 'source', 'svn2.assembla.com:/svn/phergie/trunk/Phergie/:'); 
     57        } 
    4758        //FINGER Request, reply with the not's real name 
    48         } 
    4959        else if ($ctcp == 'FINGER') 
    5060        { 
     
    5464                $finger = 'Realname: '.(!empty($realname) ? $realname: $name); 
    5565                $this->doCtcpReply($source, 'finger', $finger); 
     66        } 
    5667        // UPTIME Request, reply with the bot's uptime 
    57         } 
    5868        else if ($ctcp == 'UPTIME') 
    5969        { 
  • trunk/Phergie/Plugin/Daddy.php

    r176 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Base.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    77 
    88/** 
     
    2222        $bot = $this->getIni('nick'); 
    2323        $text = $this->event->getArgument(1); 
     24        $target = $this->event->getNick(); 
    2425        if (preg_match('/' . preg_quote($bot) . '\s*:?\s+?who\'?s y(?:our|a) ([^?]+)\??/iAD', $text, $m)) { 
    25                 if($this->getIni('curses') && rand(0,5) === 5) { 
    26                     $this->doPrivmsg($this->event->getSource(), $this->event->getNick() . ': I am your ' . $m[1] . ', bitch!'); 
     26                if($this->getIni('curses') && mt_rand(0,5) === 5) { 
     27                    $this->doPrivmsg($this->event->getSource(), $target . ': I am your ' . $m[1] . ', bitch!'); 
    2728                } else { 
    28                     $this->doPrivmsg($this->event->getSource(), 'You\'re my ' . $m[1] . ', ' . $this->event->getNick() . '!'); 
     29                    $this->doPrivmsg($this->event->getSource(), 'You\'re my ' . $m[1] . ', ' . $target . '!'); 
    2930                } 
    3031        } 
  • trunk/Phergie/Plugin/Debug.php

    r181 r194  
    22 
    33/** 
    4 * @see Phergie_Plugin_Abstract_AdminCommand 
     4* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/AdminCommand.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 
    77 
    88/** 
     
    1010* of memory consumption. 
    1111*/ 
    12 class Phergie_Plugin_Debug extends Phergie_Plugin_Abstract_AdminCommand 
     12class Phergie_Plugin_Debug extends Phergie_Plugin_Abstract_Command 
    1313{ 
     14    /** 
     15     * Flag indicating whether or not the plugin is an admin plugin or not 
     16     * 
     17     * @var bool 
     18     */ 
     19    public $needsAdmin = true; 
     20 
    1421    /** 
    1522    * Responds to requests for statistics related to the bot's memory 
     
    2027    public function onDoMem() 
    2128    { 
    22         if (function_exists('memory_get_usage') && function_exists('memory_get_peak_usage')) { 
    23             $text = 'current : '.number_format(memory_get_usage() / 1024).'KB / peak : '.number_format(memory_get_peak_usage() / 1024).'KB'; 
    24             $this->doPrivmsg($this->event->getSource(), $text); 
     29        if (function_exists('memory_get_usage')) { 
     30                $target = $this->event->getNick(); 
     31            $text = 'Current : '.number_format(memory_get_usage() / 1024).'KB' . 
     32                    (function_exists('memory_get_peak_usage') ? ' / Peak : '.number_format(memory_get_peak_usage() / 1024).'KB' : ''); 
     33            $this->doPrivmsg($this->event->getSource(), $target . ': ' . $text); 
    2534        } 
    2635    } 
     
    3342    public function onDoUptime() 
    3443    { 
    35         $uptime = 'Uptime: ' . $this->getCountdown(time() - $this->getStartTime()); 
     44       $target = $this->event->getNick(); 
    3645 
    37         $this->doPrivmsg($this->event->getSource(), $uptime); 
     46        $this->doPrivmsg($this->event->getSource(), $target . ': Uptime: ' . $this->getCountdown(time() - $this->getStartTime())); 
    3847    } 
    3948 
     
    4554    public function onDoExtensions() 
    4655    { 
     56        $target = $this->event->getNick(); 
     57 
    4758        $extensions = get_loaded_extensions(); 
    4859        if (is_array($extensions)) { 
     
    5061            sort($extensions); 
    5162        } 
    52         $this->doPrivmsg($this->event->getSource(), 'Loaded Extensions: ' . (is_array($extensions) ? implode(', ', $extensions) : 'N/A')); 
     63        $this->doPrivmsg($this->event->getSource(), $target . ': Loaded Extensions: ' . (is_array($extensions) ? implode(', ', $extensions) : 'N/A')); 
    5364        unset($extensions); 
    5465    } 
     
    6172    public function onDoGetversion($prog = null) 
    6273    { 
     74        $target = $this->event->getNick(); 
     75 
    6376        $prog = (isset($prog) ? trim(strtolower($prog)) : null); 
    6477        $extensions = get_loaded_extensions(); 
     
    6679            $extensions = array_map('strtolower', $extensions); 
    6780        } 
    68         if (!isset($prog) || empty($prog)) { 
    69                 $this->doPrivmsg($this->event->getSource(), 'Phergie Version: ' . PHERGIE_VERSION); 
     81 
     82        if (empty($prog)) { 
     83                $message = 'Phergie Version: ' . PHERGIE_VERSION; 
    7084        } else if ($prog == 'php') { 
    71                 $this->doPrivmsg($this->event->getSource(), 'PHP Version: ' . phpversion()); 
     85                $message = 'PHP Version: ' . phpversion(); 
    7286        } else if (is_array($extensions) && in_array($prog, $extensions)) { 
    73                 if ($prog == 'gd' && function_exists('gd_info')) { 
    74                         $version = gd_info(); 
    75                         $this->doPrivmsg($this->event->getSource(), 'GD Version: ' . $version['GD Version']); 
    76                 } else { 
    77                     $version = phpversion($prog); 
    78                     $this->doPrivmsg($this->event->getSource(), ucfirst($prog) . ' Version: ' . ($version ? $version : 'N/A')); 
    79             } 
     87                $version = phpversion($prog); 
     88                $message = ucfirst($prog) . ' Version: ' . ($version ? $version : 'N/A'); 
    8089        } else { 
    81                 $this->doPrivmsg($this->event->getSource(), 'Unknown Extension: ' . ucfirst($prog)); 
     90                $message = 'Unknown Extension: ' . ucfirst($prog); 
    8291        } 
    83         unset($extensions); 
     92        $this->doPrivmsg($this->event->getSource(), $target . ': ' . $message); 
     93        unset($prog, $extensions, $version, $message); 
    8494    } 
    8595} 
  • trunk/Phergie/Plugin/Dns.php

    r61 r194  
    44* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Command.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 
    77 
    88/** 
     
    2121    protected function processRequest($arg) 
    2222    { 
     23        $target = $this->event->getNick(); 
    2324        if (preg_match('/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/', $arg)) { 
    2425            $resolved = gethostbyaddr(long2ip(ip2long($arg))); 
     
    2930        $source = $this->event->getSource(); 
    3031        if (!isset ($resolved)) { 
    31             $this->doPrivmsg($source, $arg . ' cannot be resolved.'); 
     32            $this->doPrivmsg($source, $target . ': ' . $arg . ' cannot be resolved.'); 
    3233        } else { 
    33             $this->doPrivmsg($source, $arg . ' resolved to ' . $resolved); 
     34            $this->doPrivmsg($source, $target . ': ' . $arg . ' resolved to ' . $resolved); 
    3435        } 
    3536    } 
  • trunk/Phergie/Plugin/Drink.php

    r179 r194  
    44* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Command.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 
    77 
    88/** 
     
    9292            // Initialize the database connection 
    9393            $this->db = new PDO('sqlite:' . $this->dir . 'drink.db'); 
     94            if (!$this->db) { 
     95                    return; 
     96            } 
    9497 
    9598            // Populate the database if necessary 
     
    252255                continue; 
    253256            } 
    254             $this->debug('Inserted ' . $name); 
     257            $this->debug('Inserted ' . ucfirst($table) . ': ' . $name); 
    255258            $stmt->execute(array('name' => $name)); 
    256259        } 
  • trunk/Phergie/Plugin/Eval.php

    r172 r194  
    22 
    33/** 
    4 * @see Phergie_Plugin_AdminCommand 
     4* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/AdminCommand.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 
    77 
    88/** 
    99* Handles requests from administrators to evaluate a string 
    1010*/ 
    11 class Phergie_Plugin_Eval extends Phergie_Plugin_Abstract_AdminCommand 
     11class Phergie_Plugin_Eval extends Phergie_Plugin_Abstract_Command 
    1212{ 
     13    /** 
     14     * Flag indicating whether or not the plugin is an admin plugin or not 
     15     * 
     16     * @var bool 
     17     */ 
     18    public $needsAdmin = true; 
     19 
     20    /** 
     21    * Evaluates the given string and outputs the evaluated statement while any 
     22    * any dumped data gets dumped to the console. 
     23    * 
     24    * @return void 
     25    */ 
    1326        public function onDoEval($code) { 
     27                $user = $this->event->getNick(); 
     28 
    1429                // Check to see if the admin is a hostmask admin only and not an op 
    1530                if ($this->fromAdmin(false)) { 
     
    4560                                } 
    4661                        } 
     62                } else { 
     63                        $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to use eval.'); 
    4764                } 
    4865        } 
    4966 
     67    /** 
     68    * Executes the given string and outputs the last line that exec returns 
     69    * while the full exec request gets dumped to the console if the-c flag 
     70    * is specified. 
     71    * 
     72    * @return void 
     73    */ 
    5074        public function onDoExec($code) { 
     75                $user = $this->event->getNick(); 
     76 
    5177                // Check to see if the admin is a hostmask admin only and not an op 
    5278                if ($this->fromAdmin(false)) { 
     
    6995                                } 
    7096                        } 
     97                } else { 
     98                        $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to use exec.'); 
    7199                } 
    72100        } 
  • trunk/Phergie/Plugin/FeedTicker.php

    r182 r194  
    44* @see Phergie_Plugin_Abstract_Cron 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Cron.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Cron.php'; 
    77 
    88/** 
     
    1111class Phergie_Plugin_FeedTicker extends Phergie_Plugin_Abstract_Cron 
    1212{ 
     13        /** 
     14        * Determines if the plugin is a passive plugin or not 
     15        * 
     16        * @var bool 
     17        */ 
     18        public $passive = true; 
     19 
    1320    /** 
    1421    * Delay in seconds for syndicating feeds, set to 30 minutes 
     
    119126            $this->format = $this->getPluginIni('format'); 
    120127        } 
     128    } 
     129 
     130    /** 
     131    * Returns whether or not the plugin's dependencies are met. 
     132    * 
     133    * @param Phergie_Driver_Abstract $client Client instance 
     134    * @param array $plugins List of short names for plugins that the 
     135    *                       bootstrap file intends to instantiate 
     136    * @see Phergie_Plugin_Abstract_Base::checkDependencies() 
     137    * @return bool TRUE if dependencies are met, FALSE otherwise 
     138    */ 
     139    public static function checkDependencies(Phergie_Driver_Abstract $client, array $plugins) 
     140    { 
     141        if (!extension_loaded('SimpleXML')) { 
     142            return false; 
     143        } 
     144 
     145        return true; 
    121146    } 
    122147 
     
    273298    */ 
    274299    protected function decode($str, $trim = null) { 
    275           $out = $this->decodeTranslit($str); 
     300        $out = $this->decodeTranslit($str); 
    276301        if($trim > 0) { 
    277302            $out = substr($out, 0, $trim) . (strlen($out) > $trim ? '...' : ''); 
  • trunk/Phergie/Plugin/JoinPart.php

    r59 r194  
    22 
    33/** 
    4 * @see Phergie_Plugin_Abstract_AdminCommand 
     4* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/AdminCommand.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 
    77 
    88/** 
     
    1010* specified channel. 
    1111*/ 
    12 class Phergie_Plugin_JoinPart extends Phergie_Plugin_Abstract_AdminCommand 
     12class Phergie_Plugin_JoinPart extends Phergie_Plugin_Abstract_Command 
    1313{ 
     14    /** 
     15     * Flag indicating whether or not the plugin is an admin plugin or not 
     16     * 
     17     * @var bool 
     18     */ 
     19    public $needsAdmin = true; 
     20 
     21    /** 
     22    * A bool value set to whether the Users plugin is running or not 
     23    * 
     24    * @var bool 
     25    */ 
     26    protected $usersEnabled = null; 
     27 
    1428    /** 
    1529    * Joins the specified channel. 
     
    1933    public function onDoJoin($channel) 
    2034    { 
    21         $this->doJoin($channel); 
     35        if (!empty($channel)) { 
     36            $this->doJoin(trim($channel)); 
     37        } 
    2238    } 
    2339 
     
    3147    public function onDoPart($channel = null) 
    3248    { 
    33         if (empty($channel)) { 
    34             $this->doPart($this->event->getArgument(0)); 
    35         } else { 
    36             $this->doPart($channel); 
     49        $source = $this->event->getArgument(0); 
     50        $channel = trim($channel); 
     51 
     52        // If the channel is empty, part the current channel where the command was used 
     53        if (empty($channel) && $source[0] == '#') { 
     54            $this->doPart($source); 
     55        // Check whether a channel or multiple channels were given as well as a reason 
     56        } else if (preg_match('/^([#&][^\s,]+ (?:\s*,+\s* [#&][^\s,]+)* | all | \#)?(?:[\s,]+)?(.*)?$/xis', $channel, $match)) { 
     57            $channels = preg_replace(array('{\s}', '{,+}'), array('', ','), strtolower($match[1])); 
     58            if (!empty($channels) || $source[0] == '#') { 
     59                if (empty($channels) || $channels == '#') { 
     60                        if ($source[0] != '#') return; 
     61                        $channels = $source; 
     62                } else if ($channels == 'all') { 
     63                        //Check to see if the Users plugin is enabled  to retrieve a list of channels 
     64                    if (!isset($this->usersEnabled)) { 
     65                        $this->usersEnabled = $this->pluginLoaded('Users'); 
     66                    } 
     67                        if (!$this->usersEnabled) { 
     68                                 // A fallback, most IRC servers cause the user to part all channels if they try to join 0 
     69                                 $this->doJoin('0'); 
     70                        } else { 
     71                            $channels = implode(',', Phergie_Plugin_Users::getChannels()); 
     72                        } 
     73                } 
     74 
     75                $reason = trim($match[2]); 
     76                if(substr($reason, 0, 1) === '(' && substr($reason, -1) === ')') { 
     77                    $reason = trim(substr($reason, 1, -1)); 
     78                } 
     79 
     80                $this->doPart($channels, $reason); 
     81            } 
    3782        } 
     83        unset($channel, $channels, $reason); 
    3884    } 
    3985} 
  • trunk/Phergie/Plugin/Karma.php

    r179 r194  
    44* @see Phergie_Plugin_Abstract_Base 
    55*/ 
    6 require_once 'Phergie/Plugin/Abstract/Base.php'; 
     6require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Base.php'; 
    77 
    88/** 
     
    4848    */ 
    4949    protected $fixedKarma; 
     50 
     51    /** 
     52    * A list of blacklisted values 
     53    * 
     54    * @var array 
     55    */ 
     56    protected $karmaBlacklist; 
    5057 
    5158    /** 
     
    8087        $this->db = null; 
    8188        $this->lastGc = null; 
    82         $this->log = null
     89        $this->log = array()
    8390 
    8491        $this->fixedKarma = array 
     
    98105            'mc²' => '%s has karma of e', 
    99106            'i' => 'I haz big karma', 
    100