New callback _on_connect, called after 001 numeric reply reception: currently it joins channels
This commit is contained in:
parent
c32f1579ee
commit
85ec2dcd01
@ -119,7 +119,11 @@ class MessageConsumer:
|
||||
self.responses = list()
|
||||
for msg in self.msgs:
|
||||
# TODO: should be placed in server hooks
|
||||
if msg.cmd == "PING":
|
||||
if msg.cmd == "001":
|
||||
if hasattr(self.srv, "_on_connect"):
|
||||
self.srv._on_connect()
|
||||
|
||||
elif msg.cmd == "PING":
|
||||
self.srv.write("%s :%s" % ("PONG", msg.params[0]))
|
||||
|
||||
else:
|
||||
|
@ -33,6 +33,16 @@ class IRCServer(SocketServer):
|
||||
self.realname = realname
|
||||
self.id = "TODO"
|
||||
|
||||
def _on_connect():
|
||||
# First, JOIN some channels
|
||||
for chn in node.getNodes("channel"):
|
||||
if chn["password"] is not None:
|
||||
self.write("JOIN %s %s" % (chn["name"], chn["password"]))
|
||||
else:
|
||||
self.write("JOIN %s" % chn["name"])
|
||||
self._on_connect = _on_connect
|
||||
|
||||
|
||||
def _open(self):
|
||||
if SocketServer._open(self):
|
||||
if self.password is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user