From c1791c6a93944f5b27ce3885fd503055508ca600 Mon Sep 17 00:00:00 2001 From: pixlDeV <93949551+pixDeVl@users.noreply.github.com> Date: Fri, 5 Jan 2024 22:50:44 -0300 Subject: [PATCH] Add support for !log on discord through MirahezeRelay (#3586) Small changes to adminlog.py and adminlogbot.py to allow for the !log command through discord. Tested by @Universal-Omega --- modules/irc/files/logbot/adminlogbot.py | 12 +++++++++--- modules/irc/templates/logbot/config.py | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/irc/files/logbot/adminlogbot.py b/modules/irc/files/logbot/adminlogbot.py index 3c92186171..0da0d03193 100644 --- a/modules/irc/files/logbot/adminlogbot.py +++ b/modules/irc/files/logbot/adminlogbot.py @@ -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[a-z0-9._]*)> (?P.*)', 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"): @@ -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: diff --git a/modules/irc/templates/logbot/config.py b/modules/irc/templates/logbot/config.py index e1df49f769..d8ba2c0539 100644 --- a/modules/irc/templates/logbot/config.py +++ b/modules/irc/templates/logbot/config.py @@ -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" \ No newline at end of file