1
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->registerActionhandler(SMARTIRC_TYPE_NICKCHANGE, '', $bot, 'nickFinder');
$irc->login($conf->nick, 'ImgurBot', 0, $conf->nick);
$irc->join(array('#test'));
$irc->listen();
$irc->disconnect();

View File

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

View File

@ -1,6 +1,6 @@
<?php
include_once(__DIR__ . '/../Net_SmartIRC-1.0.0/SmartIRC.php');
include_once(__DIR__ . '/Net_SmartIRC-1.0.0/SmartIRC.php');
class ImgurBot {
var $imgUrl = 'http://imgur.com';
@ -9,6 +9,7 @@ class ImgurBot {
function __construct($conf) {
$this->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);