public function __construct($argc, $argv) { $this->xbot = new xbot(); // new xbot if ($argc > 1 && $argv[1] == 'debug') { self::$debug = true; } // argc $conf = file_get_contents('github.conf'); self::$config = json_decode($conf, true); if (self::$config == null) { self::debug('failed config parse, you may have comments in it, remove them :)'); die; } // config can't be parsed. self::debug('connecting to mysql (' . self::$config['mysql']['host'] . ':' . self::$config['mysql']['db'] . ')'); self::$db = mysql_connect(self::$config['mysql']['host'], self::$config['mysql']['user'], self::$config['mysql']['pass']); mysql_select_db(self::$config['mysql']['db'], self::$db); // connect to mysql foreach (self::$config['networks'] as $network => $net_data) { self::debug('connecting to (' . $network . ':' . $net_data['port'] . ') as ' . $net_data['nick']); } $this->xbot->connect(self::$config); self::debug('connected to networks'); // connect the bot $this->xbot->timer->add(array('bot', 'listen_data', array($this->xbot)), 5, 0); $this->xbot->timer->add(array('bot', 'get_new_data', array($this->xbot)), self::$config['options']['new_data_interval'], 0); // set up some timers, we only actually go hunting for new data every 30 seconds, then if new data is found its stored // the stored data is checked by listen_data every 5 seconds. We only check every 30 seconds because for huge repos like // rails/rails, which I developed this on it can be quite intensive, and plus the more often we check the quicker // we can run out of api calls (unless you get on the whitelist) $this->xbot->main('bot', 'main'); // boot the main loop w/ a callback*/ }
public function __construct() { $this->xbot = new xbot(); // new xbot; self::$config = array('networks' => array('irc.ircnode.org' => array('port' => '6667', 'nick' => 'Sam', 'ident' => 'sam', 'real' => 'Samantha', 'chans' => array('#acora' => ''))), 'ctcp' => array('version' => 'Samantha v0.1 powered by xBot Framework'), 'info_info' => 'There are {items} items in my database. I\'ve been online for {uptime} and I\'ve had {queries} queries since I\'ve been online.', 'info_replies' => array('I heard {key} {value}', '{key} {value} apparently.', '{key} {value}... I think', 'Someone said {key} {value}'), 'dont_know_replies' => array('Sorry {nick}, no idea what {key} is', '{key}? no idea {nick}'), 'info_notnew' => array('I thought {key} {value}', 'Hmm, {key} {value} ya cretin'), 'info_heard' => array('{setby} told me about {key} on {date}', 'About....{date}, I think it was {setby} that said it', 'I think it was {setby} that said it, way back on {date}'), 'info_confirm' => array('Righto', 'Aye, ok', 'You sure? Sounds a bit doggo..', 'Ok, {nick}'), 'info_locked' => array('GTFO, {nick}', 'Don\'t be silly, since when did you have control over me?'), 'info_forgot' => array('I forgot {key}'), 'info_reserved' => array('Yeah, like I am going to remember that', 'What on earth are you trying to do you decrepit fool.'), 'quiet_replies' => array('Doggo, fine..', 'Wake me up later am gan to kip!'), 'wakeup_replies' => array('Cannot be arsed with work today..', 'Hey ya bunch of faggets'), 'bot_triggers' => array('samantha,', 'samantha:', 'samantha', 'sam,', 'sam:', 'sam', 'samantha2,', 'samantha2:', 'samantha2'), 'system_phrases' => array('quote', 'lock', 'unlock', 'join', 'part', 'nick', 'invite', 'forget', 'status', 'wakeup', 'quiet', 'info'), 'mysql' => array('host' => 'localhost', 'user' => 'root', 'pass' => '', 'db' => 'samantha', 'table' => 'infobot'), 'admin_hosts' => array('wl562-633.members.linode.com')); // build a config array self::$db = mysql_connect(self::$config['mysql']['host'], self::$config['mysql']['user'], self::$config['mysql']['pass']); mysql_select_db(self::$config['mysql']['db'], self::$db); // connect to mysql $this->xbot->connect(self::$config); // connect the bot $this->xbot->main('bot', 'main'); // boot the main loop w/ a callback }