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
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
23 * Responds to various CTCP requests sent by the server and users.
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
32 class Phergie_Plugin_Ctcp extends Phergie_Plugin_Abstract
35 * Responds to a CTCP TIME request from a user with the current local
40 public function onTime()
42 $source = $this->getEvent()->getSource();
43 $this->doTime($source, strftime('%c %z'));
47 * Responds to a CTCP VERSION request from a user with the codebase
52 public function onVersion()
54 $source = $this->getEvent()->getSource();
55 $msg = 'Phergie ' . Phergie_Bot::VERSION . ' (http://phergie.org)';
56 $this->doVersion($source, $msg);
60 * Responds to a CTCP PING request from a user.
64 public function onCtcpPing()
66 $event = $this->getEvent();
67 $source = $event->getSource();
68 $handshake = $event->getArgument(1);
69 $this->doPing($source, $handshake);
73 * Responds to a CTCP FINGER request from a user.
77 public function onFinger()
79 $connection = $this->getConnection();
80 $name = $connection->getNick();
81 $realname = $connection->getRealname();
82 $username = $connection->getUsername();
85 = (empty($realname) ? $realname : $name) .
86 ' (' . (!empty($username) ? $username : $name) . ')';
88 $this->doFinger($source, $finger);