Assembla home | Assembla project page
 

root/trunk/Phergie/Plugin/Altnick.php

Revision 232, 1.1 kB (checked in by Slynderdale, 5 months ago)

Changed all instances of the method init and shutdown to onInit and onShutdown

Line 
1 <?php
2
3 /**
4  * Handles switching to alternate nicks in cases where the primary nick is not
5  * available for use.
6  */
7 class Phergie_Plugin_Altnick extends Phergie_Plugin_Abstract_Base
8 {
9     /**
10      * Determines if the plugin is a passive plugin or not
11      *
12      * @var bool
13      */
14     public $passive = true;
15
16     /**
17      * Index of the last alternate nick that the bot attempted to use
18      *
19      * @var int
20      */
21     protected $index;
22
23     /**
24      * Initializes instance variables.
25      *
26      * @return void
27      */
28     public function onInit()
29     {
30         $this->index = -1;
31     }
32
33     /**
34      * Switches to alternate nicks as needed when nick collisions occur.
35      *
36      * @return void
37      */
38     public function onResponse()
39     {
40         if ($this->event->getCode() == Phergie_Event_Response::ERR_NICKNAMEINUSE) {
41             $this->index++;
42             $altnick = $this->getPluginIni('altnick' . $this->index);
43             if ($altnick) {
44                 $this->doNick($altnick, true);
45                 $this->setIni('nick', $altnick);
46             } else {
47                 $this->doQuit('All specified nicks are in use');
48             }
49         }
50     }
51 }
52
Note: See TracBrowser for help on using the browser.