Show
Ignore:
Timestamp:
02/14/2008 11:10:34 PM (11 months ago)
Author:
Shadowhand
Message:

I, Kobot.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/kobot/controllers/kobot.php

    r2051 r2052  
    88                $bot = new Kobot('irc.freenode.net'); 
    99 
     10                // Enable debugging 
     11                $bog->log_level = 4; 
     12 
    1013                // Add triggers 
    11                 $bot->add_trigger(array($this, 'trigger_say'),  '^tell (.+?) about (.+)$') 
    12                     ->add_trigger(array($this, 'trigger_trac'), '^[r|#](\d+)$') 
    13                     ->add_trigger(array($this, 'trigger_php'),  '^([a-z_]+)$'); 
    14  
    15                 // Enable debugging 
    16                 $bog->log_level = 2; 
     14                $bot->add_trigger('^goodnight, bot$', array($this, 'trigger_quit')) 
     15                    ->add_trigger('^tell (.+?) about (.+)$', array($this, 'trigger_say')) 
     16                    ->add_trigger('^([r|#])(\d+)$', array($this, 'trigger_trac')) 
     17                    ->add_trigger('^[a-z_]+$', array($this, 'trigger_default')); 
    1718 
    1819                // Login and join the default channel 
     
    2425                // $bot->send('PRIVMSG #koboto :Go away, Shadowhand!'); 
    2526                // $bot->quit('hahahaha'); 
     27        } 
     28 
     29        public function trigger_default(Kobot $bot, array $data, array $params) 
     30        { 
     31                if (function_exists($params[0])) 
     32                { 
     33                        $bot->send('PRIVMSG '.$data['target'].' :'.$data['sender'].': http://php.net/'.$params[0]); 
     34                } 
     35        } 
     36 
     37        public function trigger_quit(Kobot $bot, array $data) 
     38        { 
     39                $bot->quit('goodnight, '.$data['sender']); 
    2640        } 
    2741 
     
    3650        } 
    3751 
     52        public function trigger_trac(Kobot $bot, array $data, array $params) 
     53        { 
     54                switch ($params[1]) 
     55                { 
     56                        case '#': 
     57                                $bot->send('PRIVMSG '.$data['target'].' :Ticket #'.$params[2].' is http://trac.kohanaphp.com/ticket/'.$params[2]); 
     58                        break; 
     59                        case 'r': 
     60                                $bot->send('PRIVMSG '.$data['target'].' :Revision r'.$params[2].' is http://trac.kohanaphp.com/changeset/'.$params[2]); 
     61                        break; 
     62                } 
     63        } 
     64 
    3865} // End