From 92d925613f55a6b4cb4698d6c23a7248cd02a632 Mon Sep 17 00:00:00 2001 From: nebula Date: Sun, 15 Dec 2024 13:32:06 -0600 Subject: [PATCH] add support for direct messages --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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: