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_Daddy
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_Daddy
23 * Simply responds to messages addressed to the bot that contain the phrase
24 * "Who's your daddy?" and related variations.
27 * @package Phergie_Plugin_Daddy
28 * @author Phergie Development Team <team@phergie.org>
29 * @license http://phergie.org/license New BSD License
30 * @link http://pear.phergie.org/package/Phergie_Plugin_Daddy
32 class Phergie_Plugin_Daddy extends Phergie_Plugin_Abstract
35 * Checks messages for the question to which it should respond and sends a
36 * response when appropriate
40 public function onPrivmsg()
42 $config = $this->getConfig();
43 $prefix = $config['command.prefix'];
44 $event = $this->getEvent();
45 $text = $event->getArgument(1);
46 $target = $event->getNick();
47 $source = $event->getSource();
49 = '/' . preg_quote($prefix) .
50 '\s*?who\'?s y(?:our|a) ([^?]+)\??/iAD';
51 if (preg_match($pattern, $text, $m)) {
52 $msg = 'You\'re my ' . $m[1] . ', ' . $target . '!';
53 $this->doPrivmsg($source, $msg);