Handle server related or specific stuff out of the pure core, in the server part (PING, CAP, CTCP requests, ...)

This commit is contained in:
nemunaire 2014-09-12 08:12:55 +02:00
parent 8c52f75b6a
commit db22436e5d
3 changed files with 95 additions and 89 deletions

View file

@ -114,31 +114,13 @@ class MessageConsumer:
self.responses = list()
for msg in self.msgs:
# TODO: should be placed in server hooks
if msg.cmd == "001":
if hasattr(self.srv, "_on_connect"):
self.srv._on_connect()
elif msg.cmd == "ERROR":
self.srv.close()
elif (msg.cmd == "CAP" and
hasattr(self.srv, "_on_caps_ls") and
self.srv._on_caps_ls(msg)):
pass
elif msg.cmd == "PING":
self.srv.write("%s :%s" % ("PONG", msg.params[0]))
else:
for h in hm.get_hooks("in", msg.cmd, msg.qual):
if h.match(message=msg, server=self.srv):
res = h.run(msg)
if isinstance(res, list):
self.responses += res
elif res is not None:
self.responses.append(res)
for h in hm.get_hooks("in", msg.cmd, msg.qual):
if h.match(message=msg, server=self.srv):
res = h.run(msg)
if isinstance(res, list):
self.responses += res
elif res is not None:
self.responses.append(res)
def post_treat(self, hm):