Join on connection

This commit is contained in:
Némunaire 2012-11-02 19:58:09 +01:00
commit 57f58eac17

View file

@ -116,9 +116,10 @@ class IRCServer(server.Server):
return chan in self.channels and (sender is None or sender return chan in self.channels and (sender is None or sender
in self.channels[chan].people) in self.channels[chan].people)
def join(self, chan, password=None): def join(self, chan, password=None, force=False):
"""Join a channel""" """Join a channel"""
if chan is not None and self.connected and chan not in self.channels: if force or (chan is not None and
self.connected and chan not in self.channels):
chn = xmlparser.module_state.ModuleState("channel") chn = xmlparser.module_state.ModuleState("channel")
chn["name"] = chan chn["name"] = chan
chn["password"] = password chn["password"] = password
@ -170,6 +171,12 @@ class IRCServer(server.Server):
self.connected = True self.connected = True
print ("Connection to %s:%d completed" % (self.host, self.port)) print ("Connection to %s:%d completed" % (self.host, self.port))
if len(self.channels) > 0:
for chn in self.channels.keys():
self.join(self.channels[chn].name,
self.channels[chn].password, force=True)
readbuffer = b'' #Here we store all the messages from server readbuffer = b'' #Here we store all the messages from server
while not self.stop: while not self.stop:
readbuffer = readbuffer + raw readbuffer = readbuffer + raw