diff --git a/main.py b/main.py index 7656612..6dc7cd9 100644 --- a/main.py +++ b/main.py @@ -297,7 +297,14 @@ class IRCBot(): channel_search = channel_re.search(line) if not channel_search: continue + name_search = name_re.search(line) channel = channel_search.group(1) + if name_search: + name = name_search.group(1) + else: + name = None + if name and not channel.startswith("#"): + channel = name try: message_body = line[line.index(" :") + 2:] except Exception as e: @@ -307,11 +314,6 @@ class IRCBot(): self.send(channel, self.helptext) continue for command, callback in self.commands: - name_search = name_re.search(line) - if name_search: - name = name_search.group(1) - else: - name = None if line.lower().endswith(command): result = callback(channel, name) if result: