def on_privmsg(self, c, e): self.check_reload(c, e) status = fb.priv_action(stateful, c, e) self.send_notices() if status: fb.render_html(conf.html_path, stateful) fb.render_rss(conf.rss_path, stateful)
def main(): global bot reload_log(conf.logfile) fb.log_tick(stateful) fb.recount_everything(stateful) fb.render_html(conf.html_path, stateful) fb.render_rss(conf.rss_path, stateful) print('Loading complete, connecting to IRC...') bot = TestBot() stateful.bot = bot bot.start() stateful.logfile.close()
def check_reload(self, c, e): global conf nick = e.source.nick message = ' '.join(e.arguments) if any(nick in nn for nn,hm in conf.admin_array) and message == 'reload-backend': try: tstart = time.time() reload(fb) tstop = time.time() conf = imp.load_source("conf", sys.argv[1]) stateful.conf = conf fb.recount_everything(stateful) fb.render_html(conf.html_path, stateful) fb.render_rss(conf.rss_path, stateful) c.privmsg(nick, 'Reload successful, %f seconds' % (tstop-tstart)) except: c.privmsg(nick, 'Reload failed.') return if any(nick in nn for nn,hm in conf.admin_array) and message == 'reload-log': try: tstart = time.time() reload_log(conf.logfile) tstop = time.time() stateful.bot = bot fb.recount_everything(stateful) fb.render_html(conf.html_path, stateful) fb.render_rss(conf.rss_path, stateful) c.privmsg(nick, 'Reload successful, %f seconds' % (tstop-tstart)) except: c.privmsg(nick, 'Reload failed.') return if any(nick in nn for nn,hm in conf.admin_array) and message == 'reload-html': try: tstart = time.time() fb.recount_everything(stateful) fb.render_html(conf.html_path, stateful) fb.render_rss(conf.rss_path, stateful) tstop = time.time() c.privmsg(nick, 'Reload successful, %f seconds' % (tstop-tstart)) except: c.privmsg(nick, 'Reload failed.') return