Changeset 196
- Timestamp:
- 03/30/08 01:01:51 (8 months ago)
- Files:
-
- trunk/Phergie/Plugin/Quit.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Reconnect.php (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Quit.php
r194 r196 20 20 21 21 /** 22 * Random reconnect messages used if a quit message isn't given 23 * 24 * @var array 25 */ 26 protected $messages = array 27 ( 28 'I\'ll be back.', 29 'I shall return.', 30 'Look to my coming at first light on the fifth day. At dawn look to the East.', 31 'kthx, brb.', 32 'Beam me up, Scotty!', 33 ); 34 35 /** 22 36 * Processes requests for the bot to disconnect from the server. 23 37 * … … 30 44 * @return void 31 45 */ 32 public function handleQuit($message = '' )46 public function handleQuit($message = '', $reconnect = false) 33 47 { 34 48 if ($this->fromAdmin(true)) { 35 $ reason = trim(!empty($message)? $message : $this->getPluginIni('reason'));36 if(substr($ reason, 0, 1) === '(' && substr($reason, -1) === ')') {37 $reason = substr($reason, 1, -1);49 $message = trim(!empty($message) || $reconnect ? $message : $this->getPluginIni('reason')); 50 if(substr($message, 0, 1) === '(' && substr($message, -1) === ')') { 51 $message = substr($message, 1, -1); 38 52 } 39 if ( empty($reason)) {40 $ reason= 'by request of %nick%';53 if (!$reconnect && empty($message)) { 54 $message = 'by request of %nick%'; 41 55 } 42 $reason = str_replace('%nick%', $this->event->getNick(), trim($reason)); 43 $this->doQuit($reason); 56 $message = str_replace('%nick%', $this->event->getNick(), trim($message)); 57 if (empty($message)) { 58 $message = $this->messages[array_rand($this->messages, 1)]; 59 } 60 $this->doQuit($message, $reconnect); 44 61 } 45 62 } … … 64 81 $this->handleQuit($message); 65 82 } 83 84 /** 85 * Reconnects to the server and rehashes the ini data 86 */ 87 public function onDoReconnect($message='') 88 { 89 $this->handleQuit($message, true); 90 } 66 91 }