Changeset 231 for trunk/Phergie/Plugin/Abstract/Command.php
- Timestamp:
- 04/13/08 23:08:08 (7 months ago)
- Files:
-
- trunk/Phergie/Plugin/Abstract/Command.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Abstract/Command.php
r223 r231 51 51 } 52 52 53 // Get the command prefix 54 $commandPrefix = trim($this->getIni('command_prefix')); 55 53 56 // Checks to see if the plugin is an admin plugin 54 if ($this->needsAdmin ) {55 $ ignorePrefix = $forceBotPrefix = true;57 if ($this->needsAdmin && empty($commandPrefix)) { 58 $forceBotPrefix = true; 56 59 } 57 60 … … 61 64 $bot = $this->getIni('nick'); 62 65 // The Botprefix regex expression 63 $exp = '( ?:' . preg_quote($bot) . '\s*[:,>]?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?' : '');66 $exp = '(' . preg_quote($bot) . '\s*[:,>]?\s+)' . (!($source[0] == '#' && $forceBotPrefix) ? '?' : ''); 64 67 65 68 if (preg_match('/^' . $exp . '(\S+)(?:[\s' . chr(240) . ']+(.*))?$/', $message, $match)) { 66 $command = strtolower($match[1]); 67 $params = isset($match[2]) ? $match[2] : array(); 69 $botPrefix = $match[1]; 70 $command = strtolower($match[2]); 71 $params = isset($match[3]) ? $match[3] : array(); 68 72 69 73 // Checks the command for a prefix if one is specified in the config 70 $commandPrefix = trim($this->getIni('command_prefix')); 71 if ($commandPrefix) { 74 if (!empty($commandPrefix)) { 72 75 if ($hasPrefix = (substr($command, 0, strlen($commandPrefix)) == $commandPrefix)) { 73 76 $command = substr($command, strlen($commandPrefix)); 74 77 } 75 if ( strtolower(substr($message, 0, strlen($bot))) == strtolower($bot)) {78 if ($botPrefix) { 76 79 $ignorePrefix = true; 77 80 } 78 81 } 79 82 80 if (( !$commandPrefix|| $hasPrefix || $ignorePrefix) && isset($this->methods[$command])) {83 if ((empty($commandPrefix) || $hasPrefix || $ignorePrefix) && isset($this->methods[$command])) { 81 84 if ($this->needsAdmin && !$this->fromAdmin()) { 82 85 $this->doNotice($user, 'You do not have permission to use the command "' . $command . '."');