Changeset 199
- Timestamp:
- 03/31/08 00:56:23 (8 months ago)
- Files:
-
- trunk/Phergie/Driver/Abstract.php (modified) (1 diff)
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (1 diff)
- trunk/Phergie/Plugin/Abstract/Command.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Eval.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Karma.php (modified) (5 diffs)
- trunk/Phergie/Plugin/Lart.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Math.php (modified) (3 diffs)
- trunk/Phergie/Plugin/ModuleList.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Nickserv.php (modified) (1 diff)
- trunk/Phergie/Plugin/Puppet.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Sed.php (modified) (1 diff)
- trunk/Phergie/Plugin/Set.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Toggle.php (modified) (5 diffs)
- trunk/Phergie/Plugin/UrbanDictionary.php (modified) (1 diff)
- trunk/Phergie/Util (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Driver/Abstract.php
r192 r199 142 142 public function addPlugin(Phergie_Plugin_Abstract_Base $plugin) 143 143 { 144 $plugin->init();145 146 144 $this->plugins[strtolower($plugin->getName())] = $plugin; 147 145 } trunk/Phergie/Plugin/Abstract/Base.php
r193 r199 116 116 $this->dir = $dir; 117 117 } 118 $this->init(); 118 119 } 119 120 trunk/Phergie/Plugin/Abstract/Command.php
r193 r199 64 64 } 65 65 66 // Checks to see if the plugin is an admin plugin and run the checks66 // Checks to see if the plugin is an admin plugin 67 67 if ($this->needsAdmin) { 68 if (!$this->fromAdmin()) {69 return;70 }71 68 $ignorePrefix = $forceBotPrefix = true; 72 69 } 73 70 74 71 // 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(); 76 74 $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) ? '?': ''); 78 77 79 78 if (preg_match('/^'.$exp.'(\S+)(?:[\s'.chr(240).']+(.*))?$/', $message, $match)) { … … 93 92 94 93 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 95 99 $method = 'onDo' . ucfirst($command); 96 100 if (empty ($params)) { trunk/Phergie/Plugin/Eval.php
r197 r199 64 64 } 65 65 } else { 66 $this->do Privmsg($this->event->getSource(), $user . ':You do not have permission to use eval.');66 $this->doNotice($user, 'You do not have permission to use eval.'); 67 67 } 68 68 } … … 106 106 } 107 107 } else { 108 $this->do Privmsg($this->event->getSource(), $user . ':You do not have permission to use exec.');108 $this->doNotice($user, 'You do not have permission to use exec.'); 109 109 } 110 110 } trunk/Phergie/Plugin/Karma.php
r194 r199 247 247 // Check the blacklist 248 248 if (is_array($this->karmaBlacklist) && in_array($term, $this->karmaBlacklist)) { 249 $this->do Privmsg($source, $target . ': ' .$term . ' is blacklisted');249 $this->doNotice($target, $term . ' is blacklisted'); 250 250 return; 251 251 } … … 280 280 $m[2] = $m[3]; # Word 281 281 } 282 $m[3] = $m[5]; # Comment282 $m[3] = (isset($m[5]) ? $m[5] : null); # Comment 283 283 unset($m[4], $m[5]); 284 284 list(,$sign, $word, $comment) = $m; 285 ; 285 286 286 // Clean the word 287 287 $word = strtolower($this->doCleanWord($word)); 288 if (empty($word)) { 289 return; 290 } 288 291 289 292 // Do nothing if the karma is fixed or blacklisted … … 294 297 295 298 // 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)) { 297 300 $this->doNotice($target, 'Bad ' . $target . '! You can not modify your own Karma. Shame on you!'); 298 301 $sign = '--'; … … 362 365 363 366 // 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)) { 365 369 return; 366 370 } … … 417 421 $word = trim($word); 418 422 if(substr($word, 0, 1) === '(' && substr($word, -1) === ')') 419 $word = substr($word, 1, -1);423 $word = trim(substr($word, 1, -1)); 420 424 $word = preg_replace('#\s+#', ' ', strtolower(trim($word))); 421 425 return $word; trunk/Phergie/Plugin/Lart.php
r198 r199 370 370 $target . ': Lart Info -> Term: '.$name.' | Definition: '.$desc.' | User: '.$host.' | Added: '.$time.' ago | Aliases: '.$aliases); 371 371 } else { 372 $this->do Privmsg($this->event->getSource(), $target . ': Unknown Lart ->' . $name);372 $this->doNotice($target, 'Unknown Lart: ' . $name); 373 373 } 374 374 unset($info); 375 375 } 376 376 } 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.'); 379 378 } 380 379 } else if (preg_match('/^(' . $nick . '\s*:?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { … … 387 386 $this->debug('Replacing term: ' . $name . ' = ' . $definition); 388 387 $this->replace->execute(array(':name' => $name, ':definition' => $definition, ':hostmask' => $hostmask, ':tstamp' => $timenow)); 389 $this->do Privmsg($this->event->getSource(), $target . ':Added lart "'. $name . '".');388 $this->doNotice($target, 'Added lart "'. $name . '".'); 390 389 $this->cache[$name] = $definition; 391 390 } 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.'); 394 392 } 395 393 } … … 400 398 $name = trim(strtolower($name)); 401 399 $this->deleteLart($name); 402 $this->do Privmsg($this->event->getSource(), $target . ':Removed lart "'. $name . '" and all its alises.');400 $this->doNotice($target, 'Removed lart "'. $name . '" and all its alises.'); 403 401 } 404 402 } 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.'); 407 404 } 408 405 } else { trunk/Phergie/Plugin/Math.php
r194 r199 47 47 protected function processRequest($expr) 48 48 { 49 $user = $this->event->getNick(); 50 49 51 // Replace constants 50 52 $equation = str_ireplace( … … 101 103 // Parse error if we've consumed the entire equation without finding anything valid 102 104 } elseif ($ptr >= strlen($equation)) { 103 $this->do Privmsg($source, 'Syntax error at "' . $substr . '" in equation "' . $equationSrc . '"');105 $this->doNotice($user, 'Syntax error at "' . $substr . '" in equation "' . $equationSrc . '"'); 104 106 return; 105 107 } else { … … 110 112 $source = $this->event->getSource(); 111 113 if($res === false) { 112 $this->do Privmsg($source, 'Computation error, division by zero?');114 $this->doNotice($user, 'Computation error, division by zero?'); 113 115 } else { 114 116 $this->doPrivmsg($source, $res); trunk/Phergie/Plugin/ModuleList.php
r194 r199 124 124 $pluginData['Passive'][] = $plugin; 125 125 } 126 127 // All plugins list 128 $pluginData['Plugins'][] = $plugin; 126 129 } 127 130 // Checks to see if the plugin is an inactive plugin or not … … 141 144 $pluginData['Verbose'][] = $plugin . (!empty($state) ? '('.trim($state).')' : ''); 142 145 } 143 // All plugins list144 $pluginData['Plugins'][] = $plugin;145 146 } 146 147 } trunk/Phergie/Plugin/Nickserv.php
r194 r199 131 131 } 132 132 } 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.'); 135 134 } 136 135 } trunk/Phergie/Plugin/Puppet.php
r194 r199 43 43 * @return void 44 44 */ 45 public function onDoAct($chan, $ message)45 public function onDoAct($chan, $action) 46 46 { 47 47 $this->doAction($chan, $action); … … 62 62 $this->doRaw($message); 63 63 } else { 64 $this->do Privmsg($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.'); 65 65 } 66 66 } trunk/Phergie/Plugin/Sed.php
r197 r199 88 88 89 89 // 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'; 91 91 if (preg_match($regex, $message, $matches)) { 92 print_r($matches); return; 92 93 list ($match, $user, $line, $pattern, $replacement, $flags1, $limit, $flags2) = array_pad($matches, 8, NULL); 93 94 // Temp fix for very similar but invalid Sed statements trunk/Phergie/Plugin/Set.php
r194 r199 48 48 file_put_contents(PHERGIE_INI_PATH, $contents); 49 49 } else { 50 $this->do Privmsg($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.'); 51 51 } 52 52 } … … 61 61 $this->doPrivmsg($this->event->getSource(), $var.' = '.$this->getIni($var)); 62 62 } else { 63 $this->do Privmsg($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.'); 64 64 } 65 65 } trunk/Phergie/Plugin/Toggle.php
r194 r199 28 28 if (($instance = $this->getPlugin($plugin)) && $instance != $this) { 29 29 $instance->enabled = false; 30 $this->do Privmsg($this->event->getSource(), $user . ':Disabled '.$plugin.'.');30 $this->doNotice($user, 'Disabled '.$plugin.'.'); 31 31 } else { 32 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' is not loaded.');32 $this->doNotice($user, 'Plugin '.$plugin.' is not loaded.'); 33 33 } 34 34 } else { 35 $this->do Privmsg($this->event->getSource(), $user . ':You do not have permission to disable plugins.');35 $this->doNotice($user, 'You do not have permission to disable plugins.'); 36 36 } 37 37 } … … 49 49 // Already enabled 50 50 if ($instance->enabled) { 51 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' was already enabled.');51 $this->doNotice($user, 'Plugin '.$plugin.' was already enabled.'); 52 52 // Not yet enabled, enable 53 53 } else { 54 54 $instance->enabled = true; 55 $this->do Privmsg($this->event->getSource(), $user . ':Enabled '.$plugin.'.');55 $this->doNotice($user, 'Enabled '.$plugin.'.'); 56 56 } 57 57 // Plugin was not loaded, try to see if we can load it … … 67 67 $this->client->addPlugin($instance); 68 68 $this->debug('Loaded ' . $plugin); 69 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' loaded.');69 $this->doNotice($user, 'Plugin '.$plugin.' loaded.'); 70 70 } else { 71 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' can not be loaded, missing dependencies.');71 $this->doNotice($user, 'Plugin '.$plugin.' can not be loaded, missing dependencies.'); 72 72 } 73 73 // Plugin file not found 74 74 } else { 75 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' not found, could not enable.');75 $this->doNotice($user, 'Plugin '.$plugin.' not found, could not enable.'); 76 76 } 77 77 } 78 78 } else { 79 $this->do Privmsg($this->event->getSource(), $user . ':You do not have permission to enable plugins.');79 $this->doNotice($user, 'You do not have permission to enable plugins.'); 80 80 } 81 81 } … … 91 91 if ($instance = $this->getPlugin($plugin)) { 92 92 if ($instance->passive && !$this->fromAdmin(false)) { 93 $this->do Privmsg($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.'); 94 94 } else { 95 95 $instance->muted[$target] = true; 96 96 $target = ($target==strtolower($this->event->getSource())?'for this channel':($target=='global'?'globally':'for '.$target)); 97 $this->do Privmsg($this->event->getSource(), $user . ':Muted '.$plugin.' '.$target.'.');97 $this->doNotice($user, 'Muted '.$plugin.' '.$target.'.'); 98 98 } 99 99 } else { 100 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' not found, could not mute.');100 $this->doNotice($user, 'Plugin '.$plugin.' not found, could not mute.'); 101 101 } 102 102 } … … 114 114 $instance->muted[$target] = false; 115 115 $target = ($target==strtolower($this->event->getSource())?'for this channel':($target=='global'?'globally':'for '.$target)); 116 $this->do Privmsg($this->event->getSource(), $user . ':Unmuted '.$plugin.' '.$target.'.');116 $this->doNotice($user, 'Unmuted '.$plugin.' '.$target.'.'); 117 117 } else { 118 $this->do Privmsg($this->event->getSource(), $user . ':Plugin '.$plugin.' not found, could not unmute.');118 $this->doNotice($user, 'Plugin '.$plugin.' not found, could not unmute.'); 119 119 } 120 120 } trunk/Phergie/Plugin/UrbanDictionary.php
r194 r199 28 28 if (strpos($contents, '<i>' . $term . '</i> isn\'t defined') !== false) { 29 29 $url = $this->tinyUrl('http://urbandictionary.com/insert.php?word=' . $term); 30 $this->do Privmsg($source, $target. ': ' .$term . ' is not defined yet [ ' . $url . ' ]');30 $this->doNotice($target, $term . ' is not defined yet [ ' . $url . ' ]'); 31 31 } else { 32 32 $start = strpos($contents, '<div class="def_p">');