Changeset 72

Show
Ignore:
Timestamp:
02/25/08 06:55:08 (5 years ago)
Author:
Seldaek
Message:

* Acronym : allowed <Nick>: ACRO?
* Daddy : added "I am your daddy, bitch!" 10% chance response (if curses is on)
* Logging : fixed "heard foo bar" triggering false positive heard answers, same for seen
* Url : caches 5 URLs now to avoid cross-bot flood
* phergie.ini : added global curses switch

Location:
trunk/Phergie
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/Phergie/Plugin/Acronym.php

    r71 r72  
    9999        $message = $this->event->getArgument(1); 
    100100 
    101         if (!preg_match('/((?:[A-Z]\.?){2,})\?/AD', $message, $acronym)) { 
     101                // Matches an optional "Nick: " followed by an acronym formatted as A.B.C. or ABC 
     102        if (!preg_match('/^(?:[A-Za-z0-9\[\]`|{}_-]+: )?((?:[A-Z]\.?){2,})\?$/', $message, $acronym)) { 
    102103            return; 
    103104        } 
  • trunk/Phergie/Plugin/Daddy.php

    r68 r72  
    2323        $text = $this->event->getArgument(1); 
    2424        if (preg_match('/' . $bot . '\s*:?\s+?who\'?s your daddy\??/iAD', $text)) { 
    25             $this->doPrivmsg($this->event->getSource(), 'You\'re my daddy, ' . $this->event->getNick() . '!'); 
     25                if($this->getIni('curses') === 'true' && rand(0,10) === 10) { 
     26                    $this->doPrivmsg($this->event->getSource(), $this->event->getNick() . ': I am your daddy, bitch!'); 
     27                } else { 
     28                    $this->doPrivmsg($this->event->getSource(), 'You\'re my daddy, ' . $this->event->getNick() . '!'); 
     29                } 
    2630        } 
    2731    } 
  • trunk/Phergie/Plugin/Logging.php

    r60 r72  
    491491    public function onDoSeen($user) 
    492492    { 
     493        // Don't match if user has a space (obviously it's not a nick) 
     494        if (strpos($user, ' ') !== false) { 
     495                return; 
     496        } 
     497 
    493498        $source = $this->event->getSource(); 
    494499        $target = $this->event->getNick(); 
     
    553558    public function onDoHeard($user) 
    554559    { 
     560        // Don't match if user has a space (obviously it's not a nick) 
     561        if (strpos($user, ' ') !== false) { 
     562                return; 
     563        } 
     564 
    555565        $source = $this->event->getSource(); 
    556566        $target = $this->event->getNick(); 
  • trunk/Phergie/Plugin/Url.php

    r71 r72  
    2323 
    2424        /** 
    25          * Saves the last url parsed to avoid spamming/looping with multiple bots 
     25         * Saves the last urls parsed to avoid spamming/looping with multiple bots 
    2626         * 
    27          * It's saved in an array containing (url, tinyurl) so both are checked 
     27         * It's saved in a flat array containing (url, tinyurl) couples so both are checked 
    2828         * 
    2929         * @var array 
    3030         */ 
    31         protected $lastUrl = array(); 
     31        protected $lastUrls = array(); 
    3232 
    3333    /** 
     
    5757            $url = rtrim($m[1], '), ]'); 
    5858            // Spam check on base URL 
    59                         if(array_search($url, $this->lastUrl) !== false) 
     59                        if(array_search($url, $this->lastUrls) !== false) 
    6060                                return; 
    6161            // Convert url 
    6262            $tinyUrl = $this->tinyUrl($url); 
    6363                        // Spam check on tinyURL 
    64                         if(array_search($tinyUrl, $this->lastUrl) !== false) 
     64                        if(array_search($tinyUrl, $this->lastUrls) !== false) 
    6565                                return; 
    6666 
     
    114114            ); 
    115115 
    116                         $this->lastUrl = array($url, $tinyUrl); 
     116                        // Remove one url couple if it exceeds 5 couples 
     117                        if (count($this->lastUrls) > 10) { 
     118                                array_shift($this->lastUrls); 
     119                                array_shift($this->lastUrls); 
     120                        } 
     121 
     122                        // Add the latest couple 
     123                        $this->lastUrls[] = $url; 
     124                        $this->lastUrls[] = $tinyUrl; 
    117125        } 
    118126    } 
  • trunk/Phergie/phergie.ini

    r71 r72  
    3333;   refer to itself in the third person for actions 
    3434gender = 
     35 
     36; curses : 
     37;   boolean flag indicating whether or not the bot is allowed to use curses, 
     38;   bad words, etc. defaults to false. 
     39curses = 
    3540 
    3641; plugins :