Changeset 2067 for trunk/modules/kobot/controllers/kobot.php
- Timestamp:
- 02/16/2008 06:06:40 PM (11 months ago)
- Files:
-
- 1 modified
-
trunk/modules/kobot/controllers/kobot.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kobot/controllers/kobot.php
r2055 r2067 9 9 10 10 // Enable debugging 11 $bog->log_level = 4;11 $bog->log_level = 1; 12 12 13 13 // Add triggers 14 14 $bot->set_trigger('^goodnight, bot$', array($this, 'trigger_quit')) 15 ->set_trigger('^register(.+)?$', array($this, 'register')) 15 16 ->set_trigger('^tell (.+?) about (.+)$', array($this, 'trigger_say')) 16 17 ->set_trigger('^([r|#])(\d+)$', array($this, 'trigger_trac')) 17 18 ->set_trigger('^[a-z_]+$', array($this, 'trigger_default')); 18 19 19 // Add timers20 $bot->set_timer(5, array($this, 'say_hi'));21 22 20 // Login and join the default channel 23 $bot->login('koboto' );21 $bot->login('koboto', 'PhoenixRisingKO'); 24 22 $bot->join('#koboto'); 25 23 $bot->read(); 26 24 } 25 26 public function register(Kobot $bot, array $data, array $params) 27 { 28 if ($data['target'] === $bot->username) 29 { 30 // Send the message back to the sender 31 $data['target'] = $data['sender']; 32 33 if (isset($params[1])) 34 { 35 if (preg_match('/[^a-z\d]+/i', $params[1])) 36 { 37 // Send the confirmation message 38 $message = 'You have been registered as '.$data['sender']; 39 } 40 else 41 { 42 // Send the registration error 43 $message = 'Passwords may only contain letters and numbers'; 44 } 45 } 46 else 47 { 48 // Send the register usage, no password was supplied 49 $message = 'Usage: register <password>'; 50 } 51 } 52 else 53 { 54 // Only allow registration in private messages 55 $message = $data['sender'].': Send me a private message: /msg '.$bot->username.' register <password>'; 56 } 57 58 // Send the response message 59 $bot->send('PRIVMSG '.$data['target'].' :'.$message); 60 } 61 27 62 28 63 public function say_hi(Kobot $bot) … … 50 85 public function trigger_say(Kobot $bot, array $data, array $params) 51 86 { 52 switch ($params[ 1])87 switch ($params[2]) 53 88 { 54 89 case 'yourself': 55 $bot->send('PRIVMSG '.$data['target'].' :Who wants to know? '.$params[ 0].'? HA!');90 $bot->send('PRIVMSG '.$data['target'].' :Who wants to know? '.$params[1].'? HA!'); 56 91 break; 57 92 }
