1
0
Fork 0

You can run but you can't hide

This commit is contained in:
Andrew Tomaka 2012-11-15 18:55:19 -05:00
parent 8ccc387b6c
commit a4e7fa83b0
3 changed files with 13 additions and 1 deletions

View file

@ -16,6 +16,9 @@ if($conf->ssl) {
$irc->connect($conf->server, $conf->port); $irc->connect($conf->server, $conf->port);
} }
$irc->registerActionhandler(SMARTIRC_TYPE_NICKCHANGE, '', $bot, 'nickFinder');
$irc->login($conf->nick, 'ImgurBot', 0, $conf->nick); $irc->login($conf->nick, 'ImgurBot', 0, $conf->nick);
$irc->join(array('#test'));
$irc->listen(); $irc->listen();
$irc->disconnect(); $irc->disconnect();

View file

@ -3,6 +3,7 @@
"server": "irc.chat.com", "server": "irc.chat.com",
"port": 6667, "port": 6667,
"target": "TestUser", "target": "TestUser",
"host": "TargetPartialHostMatch",
"timing": 100, "timing": 100,
"ssl": true, "ssl": true,
"debug": false "debug": false

View file

@ -1,6 +1,6 @@
<?php <?php
include_once(__DIR__ . '/../Net_SmartIRC-1.0.0/SmartIRC.php'); include_once(__DIR__ . '/Net_SmartIRC-1.0.0/SmartIRC.php');
class ImgurBot { class ImgurBot {
var $imgUrl = 'http://imgur.com'; var $imgUrl = 'http://imgur.com';
@ -9,6 +9,7 @@ class ImgurBot {
function __construct($conf) { function __construct($conf) {
$this->nick = $conf->nick; $this->nick = $conf->nick;
$this->target = $conf->target; $this->target = $conf->target;
$this->host = $conf->host;
} }
function quit(&$irc, &$data) { function quit(&$irc, &$data) {
@ -22,6 +23,13 @@ class ImgurBot {
$irc->message(SMARTIRC_TYPE_CHANNEL, $this->target, $this->imgUrl . '/gallery/' . $random->hash); $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 private
function getPageJson($page, $format = 'json') { function getPageJson($page, $format = 'json') {
$contents = file($this->imgUrl . '/' . $page . '.' . $format); $contents = file($this->imgUrl . '/' . $page . '.' . $format);