diff --git a/bot.php b/bot.php index ef6ea51..c7b3705 100644 --- a/bot.php +++ b/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')); diff --git a/lib/imgurbot.php b/lib/imgurbot.php index cd00c81..082cc0f 100644 --- a/lib/imgurbot.php +++ b/lib/imgurbot.php @@ -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) { - $this->target = $data->message; + 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!"); } }