diff --git a/modules/line_handler.py b/modules/line_handler.py index 72d3ad83..f722cf1d 100644 --- a/modules/line_handler.py +++ b/modules/line_handler.py @@ -187,7 +187,7 @@ class Module(ModuleManager.BaseModule): def join(self, event): account = None realname = None - channel = event["server"].channels.get(event["args"][0]) + channel_name = event["args"][0] if len(event["args"]) == 2: if not event["args"][1] == "*": @@ -195,6 +195,7 @@ class Module(ModuleManager.BaseModule): realname = event["args"][2] if not event["server"].is_own_nickname(event["prefix"].nickname): + channel = event["server"].channels.get(channel_name) user = event["server"].get_user(event["prefix"].nickname) if not user.username and not user.hostname: user.username = event["prefix"].username @@ -213,6 +214,7 @@ class Module(ModuleManager.BaseModule): user=user, server=event["server"], account=account, realname=realname) else: + channel = event["server"].channels.add(channel_name) if channel.name in event["server"].attempted_join: del event["server"].attempted_join[channel.name] self.events.on("self.join").call(channel=channel, diff --git a/src/IRCChannel.py b/src/IRCChannel.py index 6e54726a..27d7e029 100644 --- a/src/IRCChannel.py +++ b/src/IRCChannel.py @@ -170,6 +170,8 @@ class Channels(object): return self.contains(name) def __len__(self) -> int: return len(self._channels) + def __getitem__(self, name: str): + return self.get(name) def _get_id(self, channel_name: str) -> int: self._bot.database.channels.add(self._server.id, channel_name) @@ -195,8 +197,6 @@ class Channels(object): del self._channels[lower] def get(self, name: str): - if not self.contains(name): - return self.add(name) return self._channels[self._name_lower(name)] def rename(self, old_name, new_name):