]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Irc/extlib/phergie/Phergie/ExtendedBot.php
Corrected UTF8 to UTF-8
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / ExtendedBot.php
1 <?php\r
2 /**\r
3  * StatusNet - the distributed open-source microblogging tool\r
4  *\r
5  * This program is free software: you can redistribute it and/or modify\r
6  * it under the terms of the GNU Affero General Public License as published by\r
7  * the Free Software Foundation, either version 3 of the License, or\r
8  * (at your option) any later version.\r
9  *\r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU Affero General Public License for more details.\r
14  *\r
15  * You should have received a copy of the GNU Affero General Public License\r
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
17  *\r
18  * Extends the bot class (Phergie_Bot) to allow connection and access to\r
19  * sockets and to allow StatusNet to 'drive' the bot\r
20  *\r
21  * @category  Phergie\r
22  * @package   Phergie_Extended_Bot\r
23  * @author    Luke Fitzgerald <lw.fitzgerald@googlemail.com>\r
24  * @copyright 2010 StatusNet, Inc.\r
25  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0\r
26  * @link      http://status.net/\r
27  */\r
28 class Phergie_ExtendedBot extends Phergie_Bot {\r
29     /**\r
30     * Set up bot and connect to servers\r
31     *\r
32     * @return void\r
33     */\r
34     public function connect() {\r
35         $ui = $this->getUi();\r
36         $ui->setEnabled($this->getConfig('ui.enabled'));\r
37 \r
38         $this->loadPlugins();\r
39         $this->loadConnections();\r
40     }\r
41 \r
42     /**\r
43     * Transmit raw command to server using driver\r
44     *\r
45     * Handles construction of command strings and their transmission to the\r
46     * server.\r
47     *\r
48     * @param string       $command Command to send\r
49     * @param string|array $args    Optional string or array of sequential\r
50     *        arguments\r
51     *\r
52     * @return string Command string that was sent\r
53     * @throws Phergie_Driver_Exception\r
54     */\r
55     public function send($command, $args = '') {\r
56         return $this->getDriver()->send($command, $args);\r
57     }\r
58 \r
59     /**\r
60     * Handle incoming data on the socket using the handleEvents\r
61     * method of the Processor\r
62     *\r
63     * @return void\r
64     */\r
65     public function receive() {\r
66         $this->getProcessor()->handleEvents();\r
67     }\r
68 \r
69     /**\r
70     * Get the sockets used by the bot\r
71     *\r
72     * @return array Array of socket resources\r
73     */\r
74     public function getSockets() {\r
75         return $this->getDriver()->getSockets();\r
76     }\r
77 }