Skip to content

Commit

Permalink
Add support for !log on discord through MirahezeRelay (#3586)
Browse files Browse the repository at this point in the history
Small changes to adminlog.py and adminlogbot.py to allow for the !log
command through discord. Tested by @Universal-Omega
  • Loading branch information
pixDeVl authored Jan 6, 2024
1 parent f8e5826 commit c1791c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/irc/files/logbot/adminlogbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,16 @@ def on_pubmsg(self, con, event):
return
author, rest = event.source.split('!')
cloak = self.get_cloak(event.source)
line = event.arguments[0]
if rest == self.config.relay_host:
import re
parsed = re.search(r'<(?P<discord>[a-z0-9._]*)> (?P<message>.*)', line)
discord_author = "@" + parsed.group('discord')
line = parsed.group('message')
if author in self.config.author_map:
author = self.config.author_map[author]
line = event.arguments[0]

if discord_author in self.config.author_map:
discord_author = self.config.author_map[discord_author]
if (line.startswith(self.config.nick)
or line.startswith("!%s" % self.config.nick)
or line.lower() == "!log help"):
Expand Down Expand Up @@ -246,7 +252,7 @@ def on_pubmsg(self, con, event):
project = ""
message = arr[1]
try:
pageurl = adminlog.log(self.config, message, project, author)
pageurl = adminlog.log(self.config, message, project, discord_author or author)
if author in self.config.title_map:
title = self.config.title_map[author]
else:
Expand Down
3 changes: 3 additions & 0 deletions modules/irc/templates/logbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@

# Whether we "warn" or "error" if the user isn't in the trust list
required_users_mode = "warn"

# Host for to identify Relay bot for relayied log commands
relay_host = "~MirahezeR@miraheze/bot/MirahezeRelay"

0 comments on commit c1791c6

Please sign in to comment.