Assembla home | Assembla project page
 

Changeset 237

Show
Ignore:
Timestamp:
04/14/08 22:52:27 (7 months ago)
Author:
Slynderdale
Message:

Fixed up Karma so assertion requests take into account the bot name as a prefix and a command prefix if set. In Lart, lartinfo and forget now takes into account the bot name as a prefix as well as the command prefix if set. Changed TLD so tld <tld> now works such as "tld com" and "tld .com" as well as just going .com. Changed Spellcheck so both word (sp) works as well as spell and spellcheck word

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Karma.php

    r232 r237  
    362362            } 
    363363        // Assertion request 
    364         } elseif (preg_match('#^([^><]+)(<|>)([^><]+)$#', $message, $m)) { 
     364        } elseif (preg_match('#^' . $exp . '?([^><]+)(<|>)([^><]+)$#', $message, $m)) { 
    365365            // Trim words 
    366366            $word1 = strtolower($this->doCleanWord($m[1])); 
  • trunk/Phergie/Plugin/Lart.php

    r232 r237  
    319319        $message = $this->event->getArgument(1); 
    320320        $target = $this->event->getNick(); 
    321         $nick = preg_quote($this->getIni('nick')); 
    322321        $hostmask = $this->event->getHostmask(); 
    323322        $timenow = time(); 
    324323        $today = date('md'); 
     324 
     325        // Command prefix check 
     326        $prefix = preg_quote(trim($this->getIni('command_prefix'))); 
     327        $bot = preg_quote($this->getIni('nick')); 
     328        $exp = '(?:(?:' . $bot . '\s*[:,>]?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))'; 
    325329 
    326330        if ($this->flushed != $today) { 
     
    331335 
    332336        $adminOnly = $this->getPluginIni('admin_only'); 
    333         if (preg_match('/^(' . $nick . '\s*[:,>]?\s+)?lartinfo\s+(.*?)$/i', $message, $match)) { 
     337        if (preg_match('/^' . $exp . 'lartinfo\s+(.*?)$/i', $message, $match)) { 
    334338            if ($this->fromAdmin()) { 
    335                 list(, $address, $name) = array_pad($match, 3, null); 
    336                 $name = trim($name); 
     339                $name = trim($match[1]); 
    337340                if (!empty($name)) { 
    338341                    $this->select->execute(array(':name' => $name)); 
     
    358361                $this->doNotice($target, 'You do not have permission to view the lart info.'); 
    359362            } 
    360         } else if (preg_match('/^(' . $nick . '\s*[:,>]?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { 
     363        } else if (preg_match('/^(' . $bot . '\s*[:,>]?\s+)?(.*?)\s+is\s+(.*)$/i', $message, $match)) { 
    361364            list(, $address, $name, $definition) = array_pad($match, 4, null); 
    362365            if (!empty($name) && !empty($definition) && (empty($address) xor $source[0] == '#')) { 
     
    375378                } 
    376379            } 
    377         } else if (preg_match('/^(' . $nick . '\s*[:,>]?\s+)?forget\s+(.*)$/i', $message, $match)) { 
     380        } else if (preg_match('/^' . $exp . 'forget\s+(.*)$/i', $message, $match)) { 
    378381            if (!$adminOnly || $this->fromAdmin()) { 
    379382                list(, $address, $name) = array_pad($match, 3, null); 
  • trunk/Phergie/Plugin/Spellcheck.php

    r232 r237  
    6666        $target = $this->event->getNick(); 
    6767 
    68         if (preg_match('#(\S+)\s*\(sp\??\)#i', $message, $m)) { 
    69             $word = $m[1]; 
     68        // Command prefix check 
     69        $prefix = preg_quote(trim($this->getIni('command_prefix'))); 
     70        $bot = preg_quote($this->getIni('nick')); 
     71        $exp = '(?:(?:' . $bot . '\s*[:,>]?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))'; 
     72 
     73        if (preg_match('#(?:^' . $exp . 'spell(?:check)?\s+(\S+)|(\S+)\s*\(sp\??\))#i', $message, $m)) { 
     74            $word = (!empty($m[1]) ? $m[1] : $m[2]); 
    7075            if (!pspell_check($this->pspell, $word)) { 
    7176                $suggestions = pspell_suggest($this->pspell, $word); 
  • trunk/Phergie/Plugin/Tld.php

    r232 r237  
    186186 
    187187        $target = $this->event->getNick(); 
     188 
     189        // Command prefix check 
    188190        $prefix = preg_quote(trim($this->getIni('command_prefix'))); 
    189         if (preg_match('#^(?:' . preg_quote($this->getIni('nick')) . '\s*[:,>]?\s+)?(?:' . $prefix . 'tld\s+\.?([a-z]{2,10})|\.([a-z]{2,10}))$#i', $this->event->getArgument(1), $m) && 
     191        $bot = preg_quote($this->getIni('nick')); 
     192        $exp = '(?:(?:' . $bot . '\s*[:,>]?\s+(?:' . $prefix . ')?)|(?:' . $prefix . '))'; 
     193 
     194        if (preg_match('#^(?:' . $exp . 'tld\s+\.?([a-z]{2,10})$|' . $exp . '?\.([a-z]{2,10}))$#i', $this->event->getArgument(1), $m) && 
    190195            $description = self::getTld((!empty($m[1]) ? $m[1] : $m[2]))) { 
    191196            $this->doPrivmsg($this->event->getSource(),