Assembla home | Assembla project page
 

Changeset 76

Show
Ignore:
Timestamp:
02/25/08 21:55:17 (9 months ago)
Author:
Seldaek
Message:

* Streams: parameter parsing bug fixed
* Karma: supports multi-word items using (grouped by parenthesis)
* Quit: added 'die' command, same effect with different quit message
* Tld: added easter eggs (and spoons)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Driver/Streams.php

    r71 r76  
    199199                        array_unshift($args, $target); 
    200200                    } else { 
    201                         $args = explode(' :', $args); 
     201                        $args = explode(' :', $args, 2); 
    202202                    } 
    203203                    break; 
  • trunk/Phergie/Plugin/Karma.php

    r71 r76  
    7474            'mc2' => 'mc2 has karma of e', 
    7575            'mc²' => 'mc² has karma of e', 
     76            'i' => 'I haz big karma', 
    7677        ); 
    7778 
     
    118119        $source = $this->event->getSource(); 
    119120        $message = $this->event->getArgument(1); 
    120             // Karma status request 
    121         if (preg_match('#^karma (\S+?)$#i', $message, $m)) { 
     121 
     122                // Karma status request 
     123        if (preg_match('#^karma (.+)$#i', $message, $m)) { 
    122124            $term = strtolower($m[1]); 
     125            // Replaces multiple spaces by one 
     126            $term = preg_replace('#\s+#', ' ', $term); 
    123127            // Return fixed value if set 
    124128            if (isset ($this->fixedKarma[$term])) { 
     
    134138            } 
    135139        // Incrementation/decrementation request 
    136         } elseif (preg_match('#^(\S+?)(\+\+|--)\s*(.*)$#i', $message, $m)) { 
     140        } elseif (preg_match('#^(\S+?|\(.+?\)+)(\+{2,}|-{2,})(?: \s+(.*))?$#i', $message, $m)) { 
    137141            $word = strtolower($m[1]); 
    138             // Do nothing if the karma fixed 
     142            // Strip parenthesis grouping multiple words 
     143            if(substr($word, 0, 1) === '(' && substr($word, -1) === ')') { 
     144                $word = substr($word, 1, -1); 
     145            } else { // Add trailing + or -'s 
     146                if(strlen($m[2]) > 2) { 
     147                        $word .= substr($m[2], 2); 
     148                        $m[2] = substr($m[2], -2); 
     149                } 
     150            } 
     151            // Replaces multiple spaces by one 
     152            $word = preg_replace('#\s+#', ' ', $word); 
     153            // Do nothing if the karma is fixed 
    139154            if (isset($this->fixedKarma[$word])) { 
    140155                return; 
  • trunk/Phergie/Plugin/Quit.php

    r59 r76  
    2727        $this->doQuit('by request of ' . $this->event->getNick()); 
    2828    } 
     29 
     30    public function onDoDie() 
     31    { 
     32        $this->doQuit('bows to ' . $this->event->getNick() .' and commits seppuku'); 
     33    } 
    2934} 
  • trunk/Phergie/Plugin/Tld.php

    r71 r76  
    296296        'zm' => 'Zambia', 
    297297        'zw' => 'Zimbabwe', 
     298        // Pranks 
     299        'spoon' => 'Don\'t you know ? There is no spoon !', 
     300        'poo' => 'Do you really think that\'s funny ?', 
    298301    ); 
    299302