Let consumer parse the message instead of server

This commit is contained in:
nemunaire 2015-07-14 00:48:56 +02:00
commit d269468287
4 changed files with 34 additions and 7 deletions

View file

@ -257,11 +257,16 @@ class IRC(SocketServer):
def read(self):
for line in SocketServer.read(self):
# PING should be handled here, so start parsing here :/
msg = IRCMessage(line, self.encoding)
if msg.cmd in self.hookscmd:
self.hookscmd[msg.cmd](msg)
mes = msg.to_bot_message(self)
if mes is not None:
yield mes
yield msg
def parse(self, msg):
mes = msg.to_bot_message(self)
if mes is not None:
yield mes

View file

@ -139,6 +139,12 @@ class AbstractServer(io.IOBase):
self.write(vprnt.pp)
# Read
def parse(self, msg):
raise NotImplemented
# Exceptions
def exception(self):