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():