Changeset 2052 for trunk/modules/kobot/controllers/kobot.php
- Timestamp:
- 02/14/2008 11:10:34 PM (11 months ago)
- Files:
-
- 1 modified
-
trunk/modules/kobot/controllers/kobot.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kobot/controllers/kobot.php
r2051 r2052 8 8 $bot = new Kobot('irc.freenode.net'); 9 9 10 // Enable debugging 11 $bog->log_level = 4; 12 10 13 // 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')); 17 18 18 19 // Login and join the default channel … … 24 25 // $bot->send('PRIVMSG #koboto :Go away, Shadowhand!'); 25 26 // $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']); 26 40 } 27 41 … … 36 50 } 37 51 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 38 65 } // End
