Assembla home | Assembla project page
 

Changeset 199

Show
Ignore:
Timestamp:
03/31/08 00:56:23 (8 months ago)
Author:
Slynderdale
Message:

Some bug fixes and improvments. Turned a few of the user specific private messages to notices to keep down on the noise.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Driver/Abstract.php

    r192 r199  
    142142    public function addPlugin(Phergie_Plugin_Abstract_Base $plugin) 
    143143    { 
    144         $plugin->init(); 
    145  
    146144        $this->plugins[strtolower($plugin->getName())] = $plugin; 
    147145    } 
  • trunk/Phergie/Plugin/Abstract/Base.php

    r193 r199  
    116116            $this->dir = $dir; 
    117117        } 
     118        $this->init(); 
    118119    } 
    119120 
  • trunk/Phergie/Plugin/Abstract/Command.php

    r193 r199  
    6464        } 
    6565 
    66         // Checks to see if the plugin is an admin plugin and run the checks 
     66        // Checks to see if the plugin is an admin plugin 
    6767        if ($this->needsAdmin) { 
    68                 if (!$this->fromAdmin()) { 
    69                         return; 
    70                 } 
    7168                $ignorePrefix = $forceBotPrefix = true; 
    7269        } 
    7370 
    7471        // Checks to see if the command was prefixed with the bot's name 
    75         $target = $this->event->getArgument(0); 
     72        $source = $this->event->getSource(); 
     73        $user = $this->event->getNick(); 
    7674        $bot = $this->getIni('nick'); 
    77         $exp = '(?:'.preg_quote($bot).'\s*:?\s+)' . (!($target[0] == '#' && $forceBotPrefix) ? '?': ''); 
     75        // The Botprefix regex expression 
     76        $exp = '(?:'.preg_quote($bot).'\s*:?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?': ''); 
    7877 
    7978        if (preg_match('/^'.$exp.'(\S+)(?:[\s'.chr(240).']+(.*))?$/', $message, $match)) { 
     
    9392 
    9493            if ((!$commandPrefix || $hasPrefix || $ignorePrefix) && isset($this->methods[$command])) { 
     94                if ($this->needsAdmin && !$this->fromAdmin()) { 
     95                    $this->doNotice($user, 'You do not have permission to use the command "' . $command . '."'); 
     96                            return; 
     97                    } 
     98 
    9599                $method = 'onDo' . ucfirst($command); 
    96100                if (empty ($params)) { 
  • trunk/Phergie/Plugin/Eval.php

    r197 r199  
    6464                        } 
    6565                } else { 
    66                         $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to use eval.'); 
     66                        $this->doNotice($user, 'You do not have permission to use eval.'); 
    6767                } 
    6868        } 
     
    106106                        } 
    107107                } else { 
    108                         $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to use exec.'); 
     108                        $this->doNotice($user, 'You do not have permission to use exec.'); 
    109109                } 
    110110        } 
  • trunk/Phergie/Plugin/Karma.php

    r194 r199  
    247247            // Check the blacklist 
    248248            if (is_array($this->karmaBlacklist) && in_array($term, $this->karmaBlacklist)) { 
    249                 $this->doPrivmsg($source, $target . ': ' . $term . ' is blacklisted'); 
     249                $this->doNotice($target, $term . ' is blacklisted'); 
    250250                return; 
    251251            } 
     
    280280                        $m[2] = $m[3]; # Word 
    281281                } 
    282                 $m[3] = $m[5]; # Comment 
     282                $m[3] = (isset($m[5]) ? $m[5] : null); # Comment 
    283283                unset($m[4], $m[5]); 
    284284            list(,$sign, $word, $comment) = $m; 
    285 
     285 
    286286                // Clean the word 
    287287            $word = strtolower($this->doCleanWord($word)); 
     288            if (empty($word)) { 
     289                return; 
     290            } 
    288291 
    289292            // Do nothing if the karma is fixed or blacklisted 
     
    294297 
    295298            // Force a decrementation if someone tries to update his own karma 
    296             if ($word == strtolower($target) && !$this->fromAdmin(false)) { 
     299            if ($word == strtolower($target) && $sign != '--' && !$this->fromAdmin(false)) { 
    297300                $this->doNotice($target, 'Bad ' . $target . '! You can not modify your own Karma. Shame on you!'); 
    298301                $sign = '--'; 
     
    362365 
    363366            // Do nothing if the karma is fixed 
    364             if (isset($this->fixedKarma[$word1]) || isset($this->fixedKarma[$word2])) { 
     367            if (isset($this->fixedKarma[$word1]) || isset($this->fixedKarma[$word2]) || 
     368                empty($word1) || empty($word2)) { 
    365369                return; 
    366370            } 
     
    417421        $word = trim($word); 
    418422        if(substr($word, 0, 1) === '(' && substr($word, -1) === ')') 
    419             $word = substr($word, 1, -1); 
     423            $word = trim(substr($word, 1, -1)); 
    420424        $word = preg_replace('#\s+#', ' ', strtolower(trim($word))); 
    421425        return $word; 
  • trunk/Phergie/Plugin/Lart.php

    r198 r199  
    370370                                                $target . ': Lart Info -> Term: '.$name.' | Definition: '.$desc.' | User: '.$host.' | Added: '.$time.' ago | Aliases: '.$aliases); 
    371371                                        } else { 
    372                                                 $this->doPrivmsg($this->event->getSource(), $target . ': Unknown Lart -> ' . $name); 
     372                                                $this->doNotice($target, 'Unknown Lart: ' . $name); 
    373373                                        } 
    374374                                        unset($info); 
    375375                                } 
    376376                        } else { 
    377                                 $this->doPrivmsg($this->event->getSource(), 
    378                                     $target . ': You do not have permission to view the lart info.'); 
     377                                $this->doNotice($target, 'You do not have permission to view the lart info.'); 
    379378                    } 
    380379                } else if (preg_match('/^(' . $nick . '\s*:?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { 
     
    387386                                        $this->debug('Replacing term: ' . $name . ' = ' . $definition); 
    388387                                        $this->replace->execute(array(':name' => $name, ':definition' => $definition, ':hostmask' => $hostmask, ':tstamp' => $timenow)); 
    389                                         $this->doPrivmsg($this->event->getSource(), $target . ': Added lart "'. $name . '".'); 
     388                                        $this->doNotice($target, 'Added lart "'. $name . '".'); 
    390389                                        $this->cache[$name] = $definition; 
    391390                            } else { 
    392                                     $this->doPrivmsg($this->event->getSource(), 
    393                                         $target . ': You do not have permission to add larts.'); 
     391                                    $this->doNotice($target, 'You do not have permission to add larts.'); 
    394392                        } 
    395393                    } 
     
    400398                                        $name = trim(strtolower($name)); 
    401399                                        $this->deleteLart($name); 
    402                                         $this->doPrivmsg($this->event->getSource(), $target . ': Removed lart "'. $name . '" and all its alises.'); 
     400                                        $this->doNotice($target, 'Removed lart "'. $name . '" and all its alises.'); 
    403401                                } 
    404402                        } else { 
    405                                 $this->doPrivmsg($this->event->getSource(), 
    406                                     $target . ': You do not have permission to remove larts.'); 
     403                                $this->doNotice($target, 'You do not have permission to remove larts.'); 
    407404                    } 
    408405                } else { 
  • trunk/Phergie/Plugin/Math.php

    r194 r199  
    4747    protected function processRequest($expr) 
    4848    { 
     49        $user = $this->event->getNick(); 
     50 
    4951        // Replace constants 
    5052        $equation = str_ireplace( 
     
    101103            // Parse error if we've consumed the entire equation without finding anything valid 
    102104            } elseif ($ptr >= strlen($equation)) { 
    103                 $this->doPrivmsg($source, 'Syntax error at "' . $substr . '" in equation "' . $equationSrc . '"'); 
     105                $this->doNotice($user, 'Syntax error at "' . $substr . '" in equation "' . $equationSrc . '"'); 
    104106                return; 
    105107            } else { 
     
    110112        $source = $this->event->getSource(); 
    111113        if($res === false) { 
    112             $this->doPrivmsg($source, 'Computation error, division by zero?'); 
     114            $this->doNotice($user, 'Computation error, division by zero?'); 
    113115        } else { 
    114116            $this->doPrivmsg($source, $res); 
  • trunk/Phergie/Plugin/ModuleList.php

    r194 r199  
    124124                                $pluginData['Passive'][] = $plugin; 
    125125                        } 
     126 
     127                    // All plugins list 
     128                    $pluginData['Plugins'][] = $plugin; 
    126129                    } 
    127130                    // Checks to see if the plugin is an inactive plugin or not 
     
    141144                    $pluginData['Verbose'][] = $plugin . (!empty($state) ? '('.trim($state).')' : ''); 
    142145                } 
    143                 // All plugins list 
    144                 $pluginData['Plugins'][] = $plugin; 
    145146            } 
    146147        } 
  • trunk/Phergie/Plugin/Nickserv.php

    r194 r199  
    131131            } 
    132132        } else { 
    133                 $this->doPrivmsg($this->event->getSource(), 
    134                     $user . ': You do not have permission to use Ghostbust.'); 
     133                $this->doNotice($user, 'You do not have permission to use Ghostbust.'); 
    135134        } 
    136135    } 
  • trunk/Phergie/Plugin/Puppet.php

    r194 r199  
    4343    * @return void 
    4444    */ 
    45     public function onDoAct($chan, $message
     45    public function onDoAct($chan, $action
    4646    { 
    4747        $this->doAction($chan, $action); 
     
    6262            $this->doRaw($message); 
    6363        } else { 
    64                 $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to send raw messages.'); 
     64                $this->doNotice($user, 'You do not have permission to send raw messages.'); 
    6565        } 
    6666    } 
  • trunk/Phergie/Plugin/Sed.php

    r197 r199  
    8888 
    8989                // The regex used to match the Sed search/replace syntax 
    90                 $regex = '{^(?:([^\s:]+)\s*:?\s+)?%?s(\d*)/(.*?)(?<!\\\)/(.*?)(?:(?<!\\\)/([gimsx]*)(\d*)([gimsx]*))?$}ix'; 
     90                $regex = '{^(?:([^\s:]+)\s*:?\s+)?%?s(\d*)/(.*?)(?<!\\\)/(.*?)(?:(?<!\\\)/(.*))?$}ix'; 
    9191                if (preg_match($regex, $message, $matches)) { 
     92                    print_r($matches); return; 
    9293                        list ($match, $user, $line, $pattern, $replacement, $flags1, $limit, $flags2) = array_pad($matches, 8, NULL); 
    9394                        // Temp fix for very similar but invalid Sed statements 
  • trunk/Phergie/Plugin/Set.php

    r194 r199  
    4848                file_put_contents(PHERGIE_INI_PATH, $contents); 
    4949        } else { 
    50                 $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to set any settings.'); 
     50                $this->doNotice($user, 'You do not have permission to set any settings.'); 
    5151        } 
    5252    } 
     
    6161                        $this->doPrivmsg($this->event->getSource(), $var.' = '.$this->getIni($var)); 
    6262                } else { 
    63                         $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to get any settings.'); 
     63                        $this->doNotice($user, 'You do not have permission to get any settings.'); 
    6464                } 
    6565        } 
  • trunk/Phergie/Plugin/Toggle.php

    r194 r199  
    2828                        if (($instance = $this->getPlugin($plugin)) && $instance != $this) { 
    2929                                $instance->enabled = false; 
    30                                 $this->doPrivmsg($this->event->getSource(), $user . ': Disabled '.$plugin.'.'); 
     30                                $this->doNotice($user, 'Disabled '.$plugin.'.'); 
    3131                        } else { 
    32                                 $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' is not loaded.'); 
     32                                $this->doNotice($user, 'Plugin '.$plugin.' is not loaded.'); 
    3333                        } 
    3434                } else { 
    35                         $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to disable plugins.'); 
     35                        $this->doNotice($user, 'You do not have permission to disable plugins.'); 
    3636                } 
    3737        } 
     
    4949                                // Already enabled 
    5050                                if ($instance->enabled) { 
    51                                         $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' was already enabled.'); 
     51                                        $this->doNotice($user, 'Plugin '.$plugin.' was already enabled.'); 
    5252                                        // Not yet enabled, enable 
    5353                                } else { 
    5454                                        $instance->enabled = true; 
    55                                         $this->doPrivmsg($this->event->getSource(), $user . ': Enabled '.$plugin.'.'); 
     55                                        $this->doNotice($user, 'Enabled '.$plugin.'.'); 
    5656                                } 
    5757                                // Plugin was not loaded, try to see if we can load it 
     
    6767                                                $this->client->addPlugin($instance); 
    6868                                                $this->debug('Loaded ' . $plugin); 
    69                                                 $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' loaded.'); 
     69                                                $this->doNotice($user, 'Plugin '.$plugin.' loaded.'); 
    7070                                        } else { 
    71                                                 $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' can not be loaded, missing dependencies.'); 
     71                                                $this->doNotice($user, 'Plugin '.$plugin.' can not be loaded, missing dependencies.'); 
    7272                                        } 
    7373                                        // Plugin file not found 
    7474                                } else { 
    75                                         $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' not found, could not enable.'); 
     75                                        $this->doNotice($user, 'Plugin '.$plugin.' not found, could not enable.'); 
    7676                                } 
    7777                        } 
    7878                } else { 
    79                         $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to enable plugins.'); 
     79                        $this->doNotice($user, 'You do not have permission to enable plugins.'); 
    8080                } 
    8181        } 
     
    9191                if ($instance = $this->getPlugin($plugin)) { 
    9292                        if ($instance->passive && !$this->fromAdmin(false)) { 
    93                                 $this->doPrivmsg($this->event->getSource(), $user . ': You do not have permission to mute passive plugins.'); 
     93                                $this->doNotice($user, 'You do not have permission to mute passive plugins.'); 
    9494                        } else { 
    9595                            $instance->muted[$target] = true; 
    9696                            $target = ($target==strtolower($this->event->getSource())?'for this channel':($target=='global'?'globally':'for '.$target)); 
    97                             $this->doPrivmsg($this->event->getSource(), $user . ': Muted '.$plugin.' '.$target.'.'); 
     97                            $this->doNotice($user, 'Muted '.$plugin.' '.$target.'.'); 
    9898                        } 
    9999                } else { 
    100                         $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' not found, could not mute.'); 
     100                        $this->doNotice($user, 'Plugin '.$plugin.' not found, could not mute.'); 
    101101                } 
    102102            } 
     
    114114                        $instance->muted[$target] = false; 
    115115                        $target = ($target==strtolower($this->event->getSource())?'for this channel':($target=='global'?'globally':'for '.$target)); 
    116                         $this->doPrivmsg($this->event->getSource(), $user . ': Unmuted '.$plugin.' '.$target.'.'); 
     116                        $this->doNotice($user, 'Unmuted '.$plugin.' '.$target.'.'); 
    117117                } else { 
    118                         $this->doPrivmsg($this->event->getSource(), $user . ': Plugin '.$plugin.' not found, could not unmute.'); 
     118                        $this->doNotice($user, 'Plugin '.$plugin.' not found, could not unmute.'); 
    119119                    } 
    120120            } 
  • trunk/Phergie/Plugin/UrbanDictionary.php

    r194 r199  
    2828        if (strpos($contents, '<i>' . $term . '</i> isn\'t defined') !== false) { 
    2929            $url = $this->tinyUrl('http://urbandictionary.com/insert.php?word=' . $term); 
    30             $this->doPrivmsg($source, $target. ': ' . $term . ' is not defined yet [ ' . $url . ' ]'); 
     30            $this->doNotice($target, $term . ' is not defined yet [ ' . $url . ' ]'); 
    3131        } else { 
    3232            $start = strpos($contents, '<div class="def_p">');