account for the discord bridge in the core bot addressed flag

This commit is contained in:
2023-02-19 21:12:01 -06:00
parent 88ea0dbbb4
commit 55d856b8fd
2 changed files with 96 additions and 1 deletions

View File

@@ -171,7 +171,18 @@ class DrReactor(irc.client.Reactor):
else:
all_nicks = connection.get_nickname()
addressed_pattern = r'^(({nicks})[:,]|@({nicks}))\s+(?P<addressed_msg>.*)'.format(nicks=all_nicks)
match = re.match(addressed_pattern, what, re.IGNORECASE)
# ignore the first word, a nick, if the speaker is the bridge
try:
channel = IrcChannel.objects.get(name=sent_location)
if sender_nick == channel.discord_bridge:
short_what = ' '.join(what.split(' ')[1:])
match = re.match(addressed_pattern, short_what, re.IGNORECASE)
else:
match = re.match(addressed_pattern, what, re.IGNORECASE)
except IrcChannel.DoesNotExist:
match = re.match(addressed_pattern, what, re.IGNORECASE)
if match:
event.addressed = True
event.addressed_msg = match.group('addressed_msg')