From 3517616a73f47217f20b7ebe0a1cace73253ef1d Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Tue, 22 Nov 2011 23:03:52 +0100 Subject: Refactor code into Server.add_channel function --- miniircd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/miniircd b/miniircd index 74f1fc6..f0d5a01 100755 --- a/miniircd +++ b/miniircd @@ -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)] -- cgit v1.2.3