Account for rejoin
This commit is contained in:
parent
a4e7fa83b0
commit
fd58557561
2 changed files with 9 additions and 1 deletions
1
bot.php
1
bot.php
|
@ -17,6 +17,7 @@ if($conf->ssl) {
|
|||
}
|
||||
|
||||
$irc->registerActionhandler(SMARTIRC_TYPE_NICKCHANGE, '', $bot, 'nickFinder');
|
||||
$irc->registerActionhandler(SMARTIRC_TYPE_JOIN, '', $bot, 'nickFinder');
|
||||
|
||||
$irc->login($conf->nick, 'ImgurBot', 0, $conf->nick);
|
||||
$irc->join(array('#test'));
|
||||
|
|
|
@ -5,6 +5,8 @@ include_once(__DIR__ . '/Net_SmartIRC-1.0.0/SmartIRC.php');
|
|||
class ImgurBot {
|
||||
var $imgUrl = 'http://imgur.com';
|
||||
var $nick;
|
||||
var $target;
|
||||
var $host;
|
||||
|
||||
function __construct($conf) {
|
||||
$this->nick = $conf->nick;
|
||||
|
@ -25,7 +27,12 @@ class ImgurBot {
|
|||
|
||||
function nickFinder(&$irc, &$data) {
|
||||
if(preg_match("/^$this->host/", $data->host) == 1) {
|
||||
if($data->rawmessageex[1] == 'JOIN') {
|
||||
$this->target = $data->nick;
|
||||
} else {
|
||||
$this->target = $data->message;
|
||||
}
|
||||
|
||||
$irc->message(SMARTIRC_TYPE_CHANNEL, $this->target, "You can run but you can't hide!");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue