Assembla home | Assembla project page
 

Changeset 66

Show
Ignore:
Timestamp:
02/17/08 19:53:26 (9 months ago)
Author:
tobias382
Message:

* Added missing onKick handler method to the base plugin class
* Reverted Pong plugin to return hostname specified by the server
* Moved alternate nick functionality from the Nickserv plugin into its own plugin, Altnick

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Event/Handler.php

    r60 r66  
    255255 
    256256    /** 
     257    * Handler for when a user is kicked from a channel. 
     258    * 
     259    * @return void 
     260    */ 
     261    public function onKick() { } 
     262 
     263    /** 
    257264    * Handler for when the server checks the client connection to ensure 
    258265    * activity. 
  • trunk/Phergie/Plugin/Karma.php

    r60 r66  
    22 
    33/** 
    4 * @see Phergie_Event_Handler 
     4* @see Phergie_Plugin_Abstract_Command 
    55*/ 
    6 require_once 'Phergie/Event/Handler.php'; 
     6require_once 'Phergie/Plugin/Abstract/Command.php'; 
    77 
    88/** 
     
    1111* inflation or depression of counters by any single individual. 
    1212*/ 
    13 class Phergie_Plugin_Karma extends Phergie_Event_Handler 
     13class Phergie_Plugin_Karma extends Phergie_Plugin_Abstract_Command 
    1414{ 
    1515    /** 
     
    7474            'mc2' => 'mc2 has karma of e', 
    7575            'mc²' => 'mc² has karma of e', 
     76            'the meaning of life' => 'the meaning of life has a karma of 42' 
    7677        ); 
    7778 
     
    116117            return; 
    117118        } 
     119 
    118120        $source = $this->event->getSource(); 
    119121        $message = $this->event->getArgument(1); 
    120             // Karma status request 
     122        // Karma status request 
    121123        if (preg_match('#^karma (\S+?)$#i', $message, $m)) { 
    122124            $term = strtolower($m[1]); 
  • trunk/Phergie/Plugin/Nickserv.php

    r62 r66  
    1616{ 
    1717    /** 
    18     * Index of the last alternate nick that the bot attempted to use 
    19     * 
    20     * @var int 
    21     */ 
    22     protected $index; 
    23  
    24     /** 
    2518    * Primary nick for the bot 
    2619    * 
     
    3730    { 
    3831        $this->nick = $this->getIni('nick'); 
    39         $this->index = -1; 
    4032    } 
    4133 
     
    5850            } elseif (preg_match('/^.*' . $this->nick . '.* has been killed/', $message)) { 
    5951                $this->doNick($this->nick); 
    60                 $this->setIni('nick', $this->nick); 
    6152            } 
    6253        } 
     
    6455 
    6556    /** 
    66     * Switches to alternate nicks as needed when nick collisions occur. 
     57    * Changes the in-memory configuration setting for the bot nick if it is 
     58    * successfully changed. 
    6759    * 
    6860    * @return void 
    6961    */ 
    70     public function onResponse() 
     62    public function onNick() 
    7163    { 
    72         if ($this->event->getCode() == Phergie_Event_Response::ERR_NICKNAMEINUSE) { 
    73             $this->index++; 
    74             $altnick = $this->getIni('altnick' . $this->index); 
    75             if ($altnick) { 
    76                 $this->doNick($altnick); 
    77                 $this->setIni('nick', $altnick); 
    78             } 
     64        if ($this->event->getSource() == $this->getIni('nick')) { 
     65            $this->setIni('nick', $this->event->getArgument(0)); 
    7966        } 
    8067    } 
  • trunk/Phergie/Plugin/Pong.php

    r61 r66  
    1313{ 
    1414    /** 
    15     * Hostname for the bot 
    16     * 
    17     * @var string 
    18     */ 
    19     protected $hostname; 
    20  
    21     /** 
    22     * Stores the hostname for the bot to use in PONG responses. 
    23     * 
    24     * @return void 
    25     */ 
    26     public function init() 
    27     { 
    28         $this->hostname = gethostbyaddr(file_get_contents('http://whatismyip.com/automation/n09230945.asp')); 
    29     } 
    30  
    31     /** 
    3215    * Responds to PING requests from the server to indicate that the client 
    3316    * connection is still active. 
     
    3720    public function onPing() 
    3821    { 
    39         $this->doPong($this->hostname); 
     22        $this->doPong($this->event->getArgument(0)); 
    4023    } 
    4124} 
  • trunk/Phergie/phergie.ini

    r64 r66  
    1919;    nick to use for the bot 
    2020nick = 
    21  
    22 ; altnick0 : 
    23 ;    alternate nicks to use for the bot in the event that the preferred nick 
    24 ;    is unavailable; this setting may be repeated with a different number 
    25 ;    (i. e. altnick1, altnick2, etc.) 
    26 altnick0 = 
    2721 
    2822; realname : 
     
    7973;    if set to true, chan operators are given admin rights 
    8074admincommand.ops = true 
     75 
     76;----------------------------------------------------------------------------- 
     77; Alternate Nick 
     78;----------------------------------------------------------------------------- 
     79 
     80; altnick.altnick0 : 
     81;    alternate nicks to use for the bot in the event that the preferred nick 
     82;    is unavailable; this setting may be repeated with a different number 
     83;    (i. e. altnick1, altnick2, etc.) 
     84altnick.altnick0 = 
    8185 
    8286;-----------------------------------------------------------------------------