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") diff --git a/src/irc_feed.py b/src/irc_feed.py index 7da54ae..5365c30 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,11 @@ 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()) + 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 @@ -55,7 +58,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: