]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Irc/extlib/phergie/Phergie/Plugin/Daddy.php
d47c3c41d30509f3e32866a7321c2fca6bfe369e
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / Plugin / Daddy.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_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
20  */
21
22 /**
23  * Simply responds to messages addressed to the bot that contain the phrase
24  * "Who's your daddy?" and related variations.
25  *
26  * @category Phergie 
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
31  */
32 class Phergie_Plugin_Daddy extends Phergie_Plugin_Abstract
33 {
34     /**
35      * Checks messages for the question to which it should respond and sends a
36      * response when appropriate
37      *
38      * @return void
39      */
40     public function onPrivmsg()
41     {
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();
48         $pattern 
49             = '/' . preg_quote($prefix) . 
50             '\s*?who\'?s y(?:our|a) ([^?]+)\??/iAD';
51         if (preg_match($pattern, $text, $m)) {
52             if ($config['daddy.curses'] && mt_rand(0, 5) === 5) {
53                 $msg = $target . ': I am your ' . $m[1] . ', bitch!';
54             } else {
55                 $msg = 'You\'re my ' . $m[1] . ', ' . $target . '!';
56             }
57             $this->doPrivmsg($source, $msg);
58         }
59     }
60 }