replace discord bridge nick with sender nick inside the bot
when the bot has received a message through the discord bridge that it'll end up reacting to (by creating a countdown item, for instance), the nick in the event should, for all intents and purposes, be the sender's nick on the discord side, not the discord bridge itself Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
03e1269cf2
commit
e63740ca70
@ -161,8 +161,14 @@ class DrReactor(irc.client.Reactor):
|
|||||||
channel = IrcChannel.objects.get(name=sent_location)
|
channel = IrcChannel.objects.get(name=sent_location)
|
||||||
if sender_nick == channel.discord_bridge:
|
if sender_nick == channel.discord_bridge:
|
||||||
short_what = ' '.join(what.split(' ')[1:])
|
short_what = ' '.join(what.split(' ')[1:])
|
||||||
|
real_source = re.sub(r'^<(\S+)> .*', r'\1!user@discord-bridge', what)
|
||||||
|
|
||||||
match = re.match(addressed_pattern, short_what, re.IGNORECASE)
|
match = re.match(addressed_pattern, short_what, re.IGNORECASE)
|
||||||
event.arguments[0] = short_what
|
event.arguments[0] = short_what
|
||||||
|
event.source = real_source
|
||||||
|
sender_nick = irc.client.NickMask(event.source).nick
|
||||||
|
event.sender_nick = sender_nick
|
||||||
|
event.in_privmsg = sender_nick == sent_location
|
||||||
else:
|
else:
|
||||||
match = re.match(addressed_pattern, what, re.IGNORECASE)
|
match = re.match(addressed_pattern, what, re.IGNORECASE)
|
||||||
except IrcChannel.DoesNotExist:
|
except IrcChannel.DoesNotExist:
|
||||||
@ -175,10 +181,10 @@ class DrReactor(irc.client.Reactor):
|
|||||||
log.debug("all_nicks: %s, addressed: %s", all_nicks, event.addressed)
|
log.debug("all_nicks: %s, addressed: %s", all_nicks, event.addressed)
|
||||||
|
|
||||||
# only do aliasing for pubmsg/privmsg
|
# only do aliasing for pubmsg/privmsg
|
||||||
log.debug("checking for alias for %s", what)
|
log.debug("checking for alias for %s", event.arguments[0])
|
||||||
|
|
||||||
for alias in Alias.objects.all():
|
for alias in Alias.objects.all():
|
||||||
repl = alias.replace(what)
|
repl = alias.replace(event.arguments[0])
|
||||||
if repl:
|
if repl:
|
||||||
# we found an alias for our given string, doing a replace
|
# we found an alias for our given string, doing a replace
|
||||||
event.arguments[0] = repl
|
event.arguments[0] = repl
|
||||||
|
Loading…
Reference in New Issue
Block a user