Show
Ignore:
Timestamp:
02/15/2008 08:53:29 AM (11 months ago)
Author:
Shadowhand
Message:

Kobot can haz set_timer()!

Files:
1 modified

Legend:

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

    r2052 r2055  
    1212 
    1313                // Add triggers 
    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')); 
     14                $bot->set_trigger('^goodnight, bot$', array($this, 'trigger_quit')) 
     15                    ->set_trigger('^tell (.+?) about (.+)$', array($this, 'trigger_say')) 
     16                    ->set_trigger('^([r|#])(\d+)$', array($this, 'trigger_trac')) 
     17                    ->set_trigger('^[a-z_]+$', array($this, 'trigger_default')); 
     18 
     19                // Add timers 
     20                $bot->set_timer(5, array($this, 'say_hi')); 
    1821 
    1922                // Login and join the default channel 
    2023                $bot->login('koboto'); 
    2124                $bot->join('#koboto'); 
     25                $bot->read(); 
     26        } 
    2227 
    23                 $bot->read(); 
     28        public function say_hi(Kobot $bot) 
     29        { 
     30                // Say hello! 
     31                $bot->log(1, 'Just saying a timed hello!'); 
    2432 
    25                 // $bot->send('PRIVMSG #koboto :Go away, Shadowhand!'); 
    26                 // $bot->quit('hahahaha'); 
     33                // Only execute the timer once 
     34                $bot->remove_timer(array($this, __FUNCTION__)); 
    2735        } 
    2836 
     
    5563                { 
    5664                        case '#': 
    57                                 $bot->send('PRIVMSG '.$data['target'].' :Ticket #'.$params[2].' is http://trac.kohanaphp.com/ticket/'.$params[2]); 
     65                                $bot->send('PRIVMSG '.$data['target'].' :Ticket '.$params[2].', http://trac.kohanaphp.com/ticket/'.$params[2]); 
    5866                        break; 
    5967                        case 'r': 
    60                                 $bot->send('PRIVMSG '.$data['target'].' :Revision r'.$params[2].' is http://trac.kohanaphp.com/changeset/'.$params[2]); 
     68                                $bot->send('PRIVMSG '.$data['target'].' :Revision '.$params[2].', http://trac.kohanaphp.com/changeset/'.$params[2]); 
    6169                        break; 
    6270                }