From a4e7fa83b07a6a37aec00ae0af69b2531495d919 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Thu, 15 Nov 2012 18:55:19 -0500 Subject: [PATCH] You can run but you can't hide --- bot.php | 3 +++ conf/settings.conf.sample | 1 + lib/imgurbot.php | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bot.php b/bot.php index 9fcf003..ef6ea51 100644 --- a/bot.php +++ b/bot.php @@ -16,6 +16,9 @@ if($conf->ssl) { $irc->connect($conf->server, $conf->port); } +$irc->registerActionhandler(SMARTIRC_TYPE_NICKCHANGE, '', $bot, 'nickFinder'); + $irc->login($conf->nick, 'ImgurBot', 0, $conf->nick); +$irc->join(array('#test')); $irc->listen(); $irc->disconnect(); diff --git a/conf/settings.conf.sample b/conf/settings.conf.sample index 4b4232c..56d249b 100644 --- a/conf/settings.conf.sample +++ b/conf/settings.conf.sample @@ -3,6 +3,7 @@ "server": "irc.chat.com", "port": 6667, "target": "TestUser", + "host": "TargetPartialHostMatch", "timing": 100, "ssl": true, "debug": false diff --git a/lib/imgurbot.php b/lib/imgurbot.php index 233decd..cd00c81 100644 --- a/lib/imgurbot.php +++ b/lib/imgurbot.php @@ -1,6 +1,6 @@ nick = $conf->nick; $this->target = $conf->target; + $this->host = $conf->host; } function quit(&$irc, &$data) { @@ -22,6 +23,13 @@ class ImgurBot { $irc->message(SMARTIRC_TYPE_CHANNEL, $this->target, $this->imgUrl . '/gallery/' . $random->hash); } + function nickFinder(&$irc, &$data) { + if(preg_match("/^$this->host/", $data->host) == 1) { + $this->target = $data->message; + $irc->message(SMARTIRC_TYPE_CHANNEL, $this->target, "You can run but you can't hide!"); + } + } + private function getPageJson($page, $format = 'json') { $contents = file($this->imgUrl . '/' . $page . '.' . $format);