From 52417cd891a2d63fdfddda4e351a2913b15a504a Mon Sep 17 00:00:00 2001 From: Markus-Rost <37275477+Markus-Rost@users.noreply.github.com> Date: Mon, 28 Feb 2022 23:59:25 +0100 Subject: [PATCH 1/3] IRC feed support for miraheze.org --- src/irc_feed.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/irc_feed.py b/src/irc_feed.py index 7da54ae..5975a94 100644 --- a/src/irc_feed.py +++ b/src/irc_feed.py @@ -1,5 +1,5 @@ import asyncio - +import re import irc.client_aio import json import logging @@ -26,14 +26,15 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient): def on_welcome(self, connection, event): # Join IRC channels for channel in self.targets.values(): - connection.join(channel) + if channel is not None: + connection.join(channel) def on_pubmsg(self, connection, event): self.active = True if event.target == self.targets["rc"]: - self.parse_fandom_message(' '.join(event.arguments)) + self.parse_rc_message(' '.join(event.arguments)) elif event.target == self.targets["discussion"]: - self.parse_fandom_discussion(' '.join(event.arguments)) + self.parse_discussion_message(' '.join(event.arguments)) def on_nicknameinuse(self, c, e): c.nick(c.get_nickname() + "_") @@ -41,9 +42,10 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient): def on_disconnect(self, connection, event): self.connect(*self.connection_details[0], **self.connection_details[1]) # attempt to reconnect - def parse_fandom_message(self, message: str): + def parse_rc_message(self, message: str): message = message.split("\x035*\x03") # print(asyncio.all_tasks()) + message[0] = re.sub(r"^(\w+)wiki $", "\x0302https://\\1.miraheze.org/w/", message[0]) # Convert miraheze database name to wiki script path half = message[0].find("\x0302http") if half == -1: return @@ -55,7 +57,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient): self.updated.add(full_url) logger.debug("New website appended to the list! {}".format(full_url)) - def parse_fandom_discussion(self, message: str): + def parse_discussion_message(self, message: str): try: post = json.loads(message) except json.JSONDecodeError: From aa29d1ca88ad91c21294de0896c07a13176684bb Mon Sep 17 00:00:00 2001 From: Markus-Rost <37275477+Markus-Rost@users.noreply.github.com> Date: Tue, 1 Mar 2022 00:16:26 +0100 Subject: [PATCH 2/3] don't run regex on busy fandom irc --- src/irc_feed.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/irc_feed.py b/src/irc_feed.py index 5975a94..5365c30 100644 --- a/src/irc_feed.py +++ b/src/irc_feed.py @@ -45,7 +45,8 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient): def parse_rc_message(self, message: str): message = message.split("\x035*\x03") # print(asyncio.all_tasks()) - message[0] = re.sub(r"^(\w+)wiki $", "\x0302https://\\1.miraheze.org/w/", message[0]) # Convert miraheze database name to wiki script path + if self.targets["rc"] == "#miraheze-feed": + message[0] = re.sub(r"^(\w+)wiki $", "\x0302https://\\1.miraheze.org/w/", message[0]) # Convert miraheze database name to wiki script path half = message[0].find("\x0302http") if half == -1: return From 639e6da6700cebffd2bdb3f80c36b1b700cf3c83 Mon Sep 17 00:00:00 2001 From: Markus-Rost <37275477+Markus-Rost@users.noreply.github.com> Date: Mon, 11 Apr 2022 15:54:31 +0200 Subject: [PATCH 3/3] add newusers/reclaim piotrex43/RcGcDw#240 --- settings.json.example | 5 +++++ src/formatters/rc.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/settings.json.example b/settings.json.example index 8fc6340..84c3980 100644 --- a/settings.json.example +++ b/settings.json.example @@ -336,6 +336,11 @@ "color": 65280, "emoji": "🗿" }, + "newusers/reclaim": { + "icon": "", + "color": 65280, + "emoji": "🗿" + }, "managewiki/delete": { "icon": "", "color": 8421504, diff --git a/src/formatters/rc.py b/src/formatters/rc.py index 68ade18..6b4243d 100644 --- a/src/formatters/rc.py +++ b/src/formatters/rc.py @@ -303,6 +303,8 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c content = _("Account [{article}]({article_url}) was created by [{author}]({author_url}) and password was sent by email{comment}").format(article=change["title"], article_url=link, author=author, author_url=author_url, comment=parsed_comment) elif action == "newusers/newusers": content = _("Account [{author}]({author_url}) was created").format(author=author, author_url=author_url) + elif action == "newusers/reclaim": + content = _("Account [{author}]({author_url}) was reclaimed").format(author=author, author_url=author_url) elif action == "interwiki/iw_add": link = link_formatter(create_article_path("Special:Interwiki", WIKI_ARTICLE_PATH)) content = _("[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment, @@ -928,6 +930,9 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha elif action == "newusers/newusers": link = author_url embed["title"] = _("Created account") + elif action == "newusers/reclaim": + link = author_url + embed["title"] = _("Reclaimed account") elif action == "interwiki/iw_add": link = create_article_path("Special:Interwiki", WIKI_ARTICLE_PATH) embed["title"] = _("Added an entry to the interwiki table")