X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/4a8b16575ddf1f2818bae4928dad5bda3cd802f5..689e6e9590c1fbeb47bb2433ad8418b968b49a82:/erebus.py diff --git a/erebus.py b/erebus.py index 07fef14..c1ac5d0 100644 --- a/erebus.py +++ b/erebus.py @@ -5,10 +5,13 @@ #TODO: tons -import os, sys, select, MySQLdb, MySQLdb.cursors, time +import os, sys, select, MySQLdb, MySQLdb.cursors, time, random import bot, config, ctlmod class Erebus(object): + APIVERSION = 1 + RELEASE = 0 + bots = {} fds = {} numhandlers = {} @@ -117,8 +120,9 @@ class Erebus(object): def __str__(self): return self.name def __repr__(self): return "" % (self.name) - def __init__(self, trigger): - self.trigger = trigger + def __init__(self, cfg): + self.cfg = cfg + self.trigger = cfg.trigger if os.name == "posix": self.potype = "poll" self.po = select.poll() @@ -143,7 +147,7 @@ class Erebus(object): def fd(self, fileno): #get Bot() by fd/fileno return self.fds[fileno] def randbot(self): #get Bot() randomly - for b in self.bots.itervalues(): return b #TODO + return self.bots[random.choice(self.bots.keys())] def user(self, _nick, justjoined=False): nick = _nick.lower() @@ -243,7 +247,7 @@ def setup(): global cfg, main cfg = config.Config('bot.config') - main = Erebus(cfg.trigger) + main = Erebus(cfg) autoloads = [mod for mod, yes in cfg.items('autoloads') if int(yes) == 1] for mod in autoloads: