]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Irc/extlib/phergie/Phergie/Plugin/Ctcp.php
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / Plugin / Ctcp.php
1 <?php
2 /**
3  * Phergie
4  *
5  * PHP version 5
6  *
7  * LICENSE
8  *
9  * This source file is subject to the new BSD license that is bundled
10  * with this package in the file LICENSE.
11  * It is also available through the world-wide-web at this URL:
12  * http://phergie.org/license
13  *
14  * @category  Phergie
15  * @package   Phergie_Plugin_Ctcp
16  * @author    Phergie Development Team <team@phergie.org>
17  * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
18  * @license   http://phergie.org/license New BSD License
19  * @link      http://pear.phergie.org/package/Phergie_Plugin_Ctcp
20  */
21
22 /**
23  * Responds to various CTCP requests sent by the server and users.
24  *
25  * @category Phergie
26  * @package  Phergie_Plugin_Ctcp
27  * @author   Phergie Development Team <team@phergie.org>
28  * @license  http://phergie.org/license New BSD License
29  * @link     http://pear.phergie.org/package/Phergie_Plugin_Ctcp
30  * @link     http://www.irchelp.org/irchelp/rfc/ctcpspec.html
31  */
32 class Phergie_Plugin_Ctcp extends Phergie_Plugin_Abstract
33 {
34     /**
35      * Responds to a CTCP TIME request from a user with the current local
36      * time.
37      *
38      * @return void
39      */
40     public function onTime()
41     {
42         $source = $this->getEvent()->getSource();
43         $this->doTime($source, strftime('%c %z'));
44     }
45
46     /**
47      * Responds to a CTCP VERSION request from a user with the codebase
48      * version.
49      *
50      * @return void
51      */
52     public function onVersion()
53     {
54         $source = $this->getEvent()->getSource();
55         $msg = 'Phergie ' . Phergie_Bot::VERSION . ' (http://phergie.org)';
56         $this->doVersion($source, $msg);
57     }
58
59     /**
60      * Responds to a CTCP PING request from a user.
61      *
62      * @return void
63      */
64     public function onCtcpPing()
65     {
66         $event = $this->getEvent();
67         $source = $event->getSource();
68         $handshake = $event->getArgument(1);
69         $this->doPing($source, $handshake);
70     }
71
72     /**
73      * Responds to a CTCP FINGER request from a user.
74      *
75      * @return void
76      */
77     public function onFinger()
78     {
79         $connection = $this->getConnection();
80         $name = $connection->getNick();
81         $realname = $connection->getRealname();
82         $username = $connection->getUsername();
83
84         $finger
85             = (empty($realname) ? $realname : $name) .
86             ' (' . (!empty($username) ? $username : $name) . ')';
87
88         $this->doFinger($source, $finger);
89     }
90 }
91 ?>