self.log('I', line)
pieces = line.split()
+ if pieces[0][0] == ":":
+ numeric = pieces[1]
+ else:
+ numeric = pieces[0]
+
# dispatch dict
- zero = { #things to look for without source
- 'NOTICE': self._gotconnected,
- 'PING': self._gotping,
- 'ERROR': self._goterror,
- }
- one = { #things to look for after source
+ dispatch = { #things to look for after source
'NOTICE': self._gotconnected,
'001': self._got001,
'004': self._got004,
'QUIT': self._gotquit,
'NICK': self._gotnick,
'MODE': self._gotmode,
+ 'PING': self._gotping,
+ 'ERROR': self._goterror,
}
- if self.parent.hasnumhook(pieces[1]):
- hooks = self.parent.getnumhook(pieces[1])
+ if self.parent.hasnumhook(numeric):
+ hooks = self.parent.getnumhook(numeric)
for callback in hooks:
try:
callback(self, line)
except Exception:
self.__debug_cbexception("numhook", line)
- if pieces[0] in zero:
- zero[pieces[0]](pieces)
- elif pieces[1] in one:
- one[pieces[1]](pieces)
+ if numeric in dispatch:
+ dispatch[numeric](pieces)
def _gotconnected(self, pieces):
if not self.conn.registered():
curs = self.parent.query("UPDATE bots SET connected = 0")
curs.close()
except: pass
- sys.exit(2)
- os._exit(2)
+ os._exit(2) # can't use sys.exit since we might be in a sub-thread
def _got001(self, pieces):
# We wait until the end of MOTD instead to consider ourselves registered, but consider uptime as of 001
self.connecttime = time.time()
if msg.startswith("\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))
+ self.msg(user, "\001VERSION Erebus v%d.%d - http://jfr.im/git/erebus.git" % (self.parent.APIVERSION, self.parent.RELEASE))
return
triggerused = msg.startswith(self.parent.trigger)