Introducing new hooks manager

Currently, the manager use a naive implementation, this is
	mainly for architectural testing purpose.
This commit is contained in:
nemunaire 2014-09-01 19:21:54 +02:00
commit 3bc53bb4ef
14 changed files with 346 additions and 441 deletions

View file

@ -31,7 +31,7 @@ import server
#Store all used ports
PORTS = list()
class DCC(server.Server):
class DCC(server.AbstractServer):
def __init__(self, srv, dest, socket=None):
server.Server.__init__(self)

View file

@ -42,6 +42,17 @@ class IRCServer(SocketServer):
return True
return False
def send_response(self, res):
if type(res.channel) != list:
res.channel = [ res.channel ]
for channel in res.channel:
if channel is not None and channel != self.nick:
self.write("%s %s :%s" % ("PRIVMSG", channel, res.get_message()))
else:
channel = res.sender.split("!")[0]
self.write("%s %s :%s" % ("NOTICE" if res.is_ctcp else "PRIVMSG", channel, res.get_message()))
def _close(self):
self.write("QUIT")
SocketServer._close(self)

View file

@ -63,6 +63,10 @@ class AbstractServer(io.IOBase):
_xlist.remove(self)
def send_response(self, res):
return NotImplemented
def write(self, message):
"""Send a message to the server using send_callback"""
self._send_callback(message)