Changeset 141
- Timestamp:
- 03/09/08 02:45:08 (9 months ago)
- Files:
-
- trunk/Phergie/Plugin/Abstract/AdminCommand.php (modified) (1 diff)
- trunk/Phergie/Plugin/Abstract/Command.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Karma.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Abstract/AdminCommand.php
r135 r141 138 138 public function onPrivmsg() 139 139 { 140 if ($this->fromAdmin()) { 141 $target = $this->event->getArgument(0); 142 $exp = $target[0] == '#' ? 143 '/^' . $this->getIni('nick') . '\s*:?\s+(.*)$/' : 144 '/^(?:' . $this->getIni('nick') . '\s*:?\s+)?(.*)$/'; 145 if (preg_match($exp, $this->event->getArgument(1), $m)) { 146 $this->processCommand($m[1], true); 147 } 140 if ($this->fromAdmin()) { 141 $this->processCommand($this->event->getArgument(1), true, true); 148 142 } 149 143 } trunk/Phergie/Plugin/Abstract/Command.php
r137 r141 38 38 * @return void 39 39 */ 40 protected final function processCommand($message, $ignorePrefix = false )40 protected final function processCommand($message, $ignorePrefix = false, $adminCommand = false) 41 41 { 42 42 if (!$this->methods) { … … 54 54 } 55 55 56 if (preg_match('/^(\S+)(?:[\s\0xa0]+(.*))?$/', $message, $match)) { 56 // Checks to see if the command was prefixed with the bot's name 57 $target = $this->event->getArgument(0); 58 $exp = ($target[0] == '#' && $adminCommand) ? 59 '(?:' . $this->getIni('nick') . '\s*:?\s+)' : 60 '(?:' . $this->getIni('nick') . '\s*:?\s+)?'; 61 62 if (preg_match('/^'.$exp.'(\S+)(?:[\s\0xa0]+(.*))?$/', $message, $match)) { 57 63 $command = strtolower($match[1]); 58 64 $params = isset ($match[2]) ? $match[2] : array(); trunk/Phergie/Plugin/Karma.php
r136 r141 210 210 211 211 // Command prefix check 212 $commandPrefix = trim($this->getIni('command_prefix'));213 $prefix = preg_quote($commandPrefix ? $commandPrefix : '');212 $commandPrefix = preg_quote(trim($this->getIni('command_prefix'))); 213 $prefix = ($commandPrefix ? $commandPrefix . '|' : '').'(?:' . $this->getIni('nick') . '\s*:?\s+)?'; 214 214 215 215 // Karma status request 216 if (preg_match('#^ '.$prefix.'karma\s+(.+)$#i', $message, $m)) {216 if (preg_match('#^(?:'.$prefix.')karma\s+(.+)$#i', $message, $m)) { 217 217 // Return user's value if "me" is requested 218 218 if (strtolower($m[1]) === 'me') {