From: zonidjan Date: Mon, 24 Aug 2015 23:09:10 +0000 (-0500) Subject: add ctcp version reply X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/a76c4bd839599267b085866245396a2cf88e202c?hp=4a8b16575ddf1f2818bae4928dad5bda3cd802f5 add ctcp version reply --- diff --git a/bot.py b/bot.py index 4b1fc25..ca7dc37 100644 --- a/bot.py +++ b/bot.py @@ -101,6 +101,11 @@ class Bot(object): pieces = msg.split() if target == self.nick: + if msg[0] == "\001": #ctcp + msg = msg.strip("\001") + if msg == "VERSION": + self.msg(user, "\001VERSION Erebus v%d.%d - http://github.com/zonidjan/erebus" % (self.parent.APIVERSION, self.parent.RELEASE)) + return if len(pieces) > 1: chanword = pieces[1] if chanword[0] == '#': @@ -121,11 +126,9 @@ class Bot(object): cbret = callback(self, user, chan, *pieces) if cbret is NotImplemented: self.msg(user, "Command not implemented.") - return - else: - return # not to bot, don't process! + return # not to bot, don't process! except IndexError: - return # Fix if you feel like it /BiohZn + return # "message" is empty cmd = pieces[0].lower() diff --git a/ctlmod.py b/ctlmod.py index b8244a8..9a30c7e 100644 --- a/ctlmod.py +++ b/ctlmod.py @@ -18,7 +18,7 @@ def load(parent, modname): if not hasattr(mod, 'modinfo'): return modlib.error('no modinfo') - if 1 not in mod.modinfo['compatible']: + if parent.APIVERSION not in mod.modinfo['compatible']: return modlib.error('API-incompatible') modules[modname] = mod diff --git a/erebus.py b/erebus.py index 07fef14..f24d60a 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 = {} @@ -143,7 +146,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 random.choice(self.bots) def user(self, _nick, justjoined=False): nick = _nick.lower()