diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2011-11-22 23:03:52 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2011-11-23 22:24:48 +0100 |
commit | 3517616a73f47217f20b7ebe0a1cace73253ef1d (patch) | |
tree | 2e723e2cd6fbae3c5938d1c885b320483fe77b9e | |
parent | 60b4d67273ef0aaf04d9364b7f1317c61018229e (diff) | |
download | miniircd-3517616a73f47217f20b7ebe0a1cace73253ef1d.tar.gz miniircd-3517616a73f47217f20b7ebe0a1cace73253ef1d.zip |
Refactor code into Server.add_channel function
-rwxr-xr-x | miniircd | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -205,7 +205,6 @@ class Client(object): continue server.add_member_to_channel(self, channelname) channel = server.get_channel(channelname) - self.channels[irc_lower(channelname)] = channel self.message_channel(channel, "JOIN", channelname, True) self.channel_log(channel, "joined", meta=True) if channel.topic: @@ -640,8 +639,7 @@ class Server(object): if irc_lower(channelname) in self.channels: channel = self.channels[irc_lower(channelname)] else: - channel = Channel(self, channelname) - self.channels[irc_lower(channelname)] = channel + channel = self.add_channel(channelname) channel.add_member(client) def remove_member_from_channel(self, client, channelname): @@ -659,6 +657,11 @@ class Server(object): del self.nicknames[irc_lower(client.nickname)] del self.clients[client.socket] + def add_channel(self, name): + channel = Channel(self, channelname) + self.channels[irc_lower(channelname)] = channel + return channel + def remove_channel(self, channel): del self.channels[irc_lower(channel.name)] |