Assembla home | Assembla project page
 

Changeset 143

Show
Ignore:
Timestamp:
03/09/08 03:34:02 (9 months ago)
Author:
Slynderdale
Message:

Made it so only hostmask admins can make the bot quit or reconnect from the server but ops can still make the bot part. Also added the ability to give the bot a custom quit message when calling quit and reconnect.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Quit.php

    r93 r143  
    2323    * @return void 
    2424    */ 
    25     public function handleQuit(
     25    public function handleQuit($message=''
    2626    { 
    27         $reason = $this->getPluginIni('reason'); 
    28         if (empty($reason)) { 
    29             $reason = 'by request of %nick%'; 
     27        if ($this->fromAdmin(true)) { 
     28            $reason = trim(!empty($message) ? $message : $this->getPluginIni('reason')); 
     29            if(substr($reason, 0, 1) === '(' && substr($reason, -1) === ')') { 
     30                $reason = substr($reason, 1, -1); 
     31            } 
     32            if (empty($reason)) { 
     33                $reason = 'by request of %nick%'; 
     34            } 
     35            $reason = str_replace('%nick%', $this->event->getNick(), trim($reason)); 
     36            $this->doQuit($reason); 
    3037        } 
    31         $reason = str_replace('%nick%', $this->event->getNick(), $reason); 
    32         $this->doQuit($reason); 
    3338    } 
    3439 
    35     public function onDoQuit(
     40    public function onDoQuit($message=''
    3641    { 
    37         $this->handleQuit(); 
     42        $this->handleQuit($message); 
    3843    } 
    3944 
    40     public function onDoDie(
     45    public function onDoDie($message=''
    4146    { 
    42         $this->handleQuit();  
     47        $this->handleQuit($message); 
    4348    } 
    4449} 
  • trunk/Phergie/Plugin/Reconnect.php

    r122 r143  
    2222        ); 
    2323 
    24     public function onDoReconnect(
     24    public function onDoReconnect($message=''
    2525    { 
    26         $this->doQuit($this->messages[array_rand($this->messages, 1)], true); 
     26        if ($this->fromAdmin(true)) { 
     27            $message = trim($message); 
     28            if(substr($message, 0, 1) === '(' && substr($message, -1) === ')') { 
     29                $message = substr($message, 1, -1); 
     30            } 
     31            $this->doQuit((!empty($message)?trim($message):$this->messages[array_rand($this->messages, 1)]), true); 
     32        } 
    2733    } 
    2834}