add support for direct messages

main
nebula 2024-12-15 13:32:06 -06:00
parent a59fcf0adb
commit 92d925613f
1 changed files with 7 additions and 5 deletions

12
main.py
View File

@ -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: