From 3dbb377630ce8a6511f880f0fb9851eecb38c74c Mon Sep 17 00:00:00 2001 From: Frisk Date: Mon, 30 Nov 2020 14:21:54 +0100 Subject: [PATCH] Fixed QUADRUPLE MESSAGES WOW --- locale/de/LC_MESSAGES/discord.mo | Bin 755 -> 833 bytes locale/de/LC_MESSAGES/rc_formatters.po | 2 +- locale/pl/LC_MESSAGES/discord.mo | Bin 847 -> 930 bytes locale/pl/LC_MESSAGES/rc_formatters.po | 2 +- locale/pt-br/LC_MESSAGES/discord.mo | Bin 773 -> 850 bytes locale/pt-br/LC_MESSAGES/rc_formatters.po | 2 +- locale/templates/discord.pot | 2 +- locale/templates/discussion_formatters.pot | 2 +- locale/templates/misc.pot | 2 +- locale/templates/rc_formatters.pot | 2 +- locale/templates/wiki.pot | 2 +- locale/widgets/de.png | Bin 2475 -> 2475 bytes locale/widgets/hi.png | Bin 2475 -> 2475 bytes locale/widgets/pl.png | Bin 2553 -> 2553 bytes locale/widgets/pt-br.png | Bin 2553 -> 2553 bytes locale/widgets/ru.png | Bin 2532 -> 2532 bytes locale/widgets/zh-hans.png | Bin 2270 -> 2270 bytes scripts/generate_translations.sh | 2 +- src/bot.py | 8 ++++---- src/formatters/rc.py | 5 ++--- src/msgqueue.py | 15 ++++++++++----- 21 files changed, 25 insertions(+), 21 deletions(-) diff --git a/locale/de/LC_MESSAGES/discord.mo b/locale/de/LC_MESSAGES/discord.mo index 5704f08d12ffb81ce46fbef3ab22ee19088d9094..0f0814e0ed4b6882d98934f2ac85dfca75a617cf 100644 GIT binary patch delta 234 zcmey&dXTODo)F7a1|VPqVi_Rz0b*_-t^r~YSOLT~K)e!&MS%Dj5c2}@Zy@FYVopW| z20%^sw8-H(PWHg+- LmdSlGFS7{%$DtGR diff --git a/locale/de/LC_MESSAGES/rc_formatters.po b/locale/de/LC_MESSAGES/rc_formatters.po index 89e4299..5638938 100644 --- a/locale/de/LC_MESSAGES/rc_formatters.po +++ b/locale/de/LC_MESSAGES/rc_formatters.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-29 00:18+0100\n" +"POT-Creation-Date: 2020-11-29 00:25+0100\n" "PO-Revision-Date: 2020-11-28 22:58+0000\n" "Last-Translator: MarkusRost \n" "Language-Team: German rB3E!b_4)|t;? F0|4}d5Q_i+ diff --git a/locale/pl/LC_MESSAGES/rc_formatters.po b/locale/pl/LC_MESSAGES/rc_formatters.po index b9a2bfc..035057b 100644 --- a/locale/pl/LC_MESSAGES/rc_formatters.po +++ b/locale/pl/LC_MESSAGES/rc_formatters.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDw\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-29 00:18+0100\n" +"POT-Creation-Date: 2020-11-29 00:25+0100\n" "PO-Revision-Date: 2020-11-20 09:22+0000\n" "Last-Translator: Frisk The Evil Goat Overlord \n" "Language-Team: Polish ygAYKW?B0&5MhpF delta 164 zcmcb_*2-3YPl#nI0}!wRu?!Hq05Lld=KwJXbO5mp5O)GGFAyICVjdvA0>pwq{1Av| zFfuTF2GaIG+`|MBKLe!sfc$$vS{z8f1=2ueaKHj&0fpEYn1Kw|iAx\n" "Language-Team: Portuguese (Brazil) \n" "Language-Team: LANGUAGE \n" diff --git a/locale/templates/discussion_formatters.pot b/locale/templates/discussion_formatters.pot index 9e0bbf7..840282a 100644 --- a/locale/templates/discussion_formatters.pot +++ b/locale/templates/discussion_formatters.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDb\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-29 00:18+0100\n" +"POT-Creation-Date: 2020-11-29 00:25+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/templates/misc.pot b/locale/templates/misc.pot index 4103f50..264c65c 100644 --- a/locale/templates/misc.pot +++ b/locale/templates/misc.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDb\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-29 00:18+0100\n" +"POT-Creation-Date: 2020-11-29 00:25+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/templates/rc_formatters.pot b/locale/templates/rc_formatters.pot index b16bf51..5c85908 100644 --- a/locale/templates/rc_formatters.pot +++ b/locale/templates/rc_formatters.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDb\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-29 00:18+0100\n" +"POT-Creation-Date: 2020-11-29 00:25+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/templates/wiki.pot b/locale/templates/wiki.pot index 13a2957..ef5455a 100644 --- a/locale/templates/wiki.pot +++ b/locale/templates/wiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDb\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-29 00:18+0100\n" +"POT-Creation-Date: 2020-11-29 00:25+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/locale/widgets/de.png b/locale/widgets/de.png index 85bc5e460f1ef9c913549447a09a1505cdaecd12..15b2e7d24a4ac8b5ebdf6e4d8a20117ee4400b6d 100644 GIT binary patch delta 47 tcmZ22yjpmJ6(_%usg;3|wt<0_fkBRk# diff --git a/locale/widgets/hi.png b/locale/widgets/hi.png index 85bc5e460f1ef9c913549447a09a1505cdaecd12..ff183519a77a7587cb4433887904ac5485564236 100644 GIT binary patch delta 47 tcmZ22yjpmJ6(_%usg;3=wt<0_fdT&vor#k@IhByb>W)s)om|Cf2mmH(4441_ delta 47 tcmZ22yjpmJ6(_%;g_W^^wt<0_fq|sUqYINgIhBybG9;sNCRcG90st}w42S># diff --git a/locale/widgets/pl.png b/locale/widgets/pl.png index ac4faba07623ac1075d7effba93f14134dde557c..6479dd48a428bc52952a9b5da89db30169c5754a 100644 GIT binary patch delta 47 tcmew<{8M;C2PeOgsg;4bwt<0_fq`9t8PDYDoJz=I{i%1OPMF46pzI delta 47 tcmca7cu#OcE(gD%g_W_1wt<0_fx%nuV}~c#a3~>*%?YckpS+gC5CCIK4x#`6 diff --git a/scripts/generate_translations.sh b/scripts/generate_translations.sh index e9a15fd..d8e2cf2 100755 --- a/scripts/generate_translations.sh +++ b/scripts/generate_translations.sh @@ -6,7 +6,7 @@ xgettext -L Python --package-name=RcGcDb -o locale/templates/discord.pot src/dis xgettext -L Python --package-name=RcGcDb -o locale/templates/misc.pot src/misc.py declare -a StringArray=("discussion_formatters" "rc_formatters" "discord" "wiki" "misc") -for language in de pl pt-br +for language in de pl pt-br hi ru uk do for file in ${StringArray[@]}; do msgmerge -U locale/$language/LC_MESSAGES/$file.po locale/templates/$file.pot diff --git a/src/bot.py b/src/bot.py index 48e9f55..bb54515 100644 --- a/src/bot.py +++ b/src/bot.py @@ -357,12 +357,12 @@ async def discussion_handler(): try: while True: fetch_all = db_cursor.execute( - "SELECT wiki, rcid, postid FROM rcgcdw WHERE postid != '-1' OR postid IS NULL") + "SELECT wiki, rcid, postid FROM rcgcdw WHERE postid != '-1' OR postid IS NULL GROUP BY wiki") for db_wiki in fetch_all.fetchall(): header = settings["header"] header["Accept"] = "application/hal+json" async with aiohttp.ClientSession(headers=header, - timeout=aiohttp.ClientTimeout(6.0)) as session: + timeout=aiohttp.ClientTimeout(6.0)) as session: try: local_wiki = all_wikis[db_wiki["wiki"]] # set a reference to a wiki object from memory except KeyError: @@ -379,7 +379,7 @@ async def discussion_handler(): if error == "site doesn't exists": # Discussions disabled if db_wiki["rcid"] != -1: # RC feed is disabled db_cursor.execute("UPDATE rcgcdw SET postid = ? WHERE wiki = ?", - ("-1", db_wiki["wiki"],)) + ("-1", db_wiki["wiki"],)) else: await local_wiki.remove(db_wiki["wiki"], 1000) DBHandler.update_db() @@ -450,8 +450,8 @@ async def discussion_handler(): await send_to_discord(message) if discussion_feed: DBHandler.add(db_wiki["wiki"], post["id"], True) + DBHandler.update_db() await asyncio.sleep(delay=2.0) # hardcoded really doesn't need much more - DBHandler.update_db() except asyncio.CancelledError: pass except: diff --git a/src/formatters/rc.py b/src/formatters/rc.py index 57b6295..ce05ab2 100644 --- a/src/formatters/rc.py +++ b/src/formatters/rc.py @@ -8,7 +8,6 @@ import datetime from src.config import settings from src.misc import link_formatter, create_article_path, parse_link, profile_field_name, ContentParser from src.discord import DiscordMessage -from src.msgqueue import send_to_discord from src.i18n import langs from bs4 import BeautifulSoup @@ -211,14 +210,14 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c author_url=author_url, target=target_user, target_url=link, - field=profile_field_name(change["logparams"]['4:section'], False), + field=profile_field_name(change["logparams"]['4:section'], False, message_target[0][0]), desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text()) else: content = "📌 " + _("[{author}]({author_url}) edited the {field} on [their own]({target_url}) profile. *({desc})*").format( author=author, author_url=author_url, target_url=link, - field=profile_field_name(change["logparams"]['4:section'], False), + field=profile_field_name(change["logparams"]['4:section'], False, message_target[0][0]), desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text()) elif action in ("rights/rights", "rights/autopromote"): link = link_formatter(create_article_path("User:{user}".format(user=change["title"].split(":")[1]), WIKI_ARTICLE_PATH)) diff --git a/src/msgqueue.py b/src/msgqueue.py index 4b74d69..8f1ef53 100644 --- a/src/msgqueue.py +++ b/src/msgqueue.py @@ -25,6 +25,7 @@ class MessageQueue: def add_message(self, message): self._queue.append(message) + logger.debug("Adding new message") # # def replace_message(self, to_replace: DiscordMessage, with_replace: StackedDiscordMessage): # try: @@ -56,7 +57,10 @@ class MessageQueue: if status[0] < 2: logger.debug("Sending message succeeded") try: - self._queue.remove(msg) + if len(msg.webhook_url) > 1: + msg.webhook_url.remove(webhook_url) + else: + self._queue.remove(msg) except ValueError: # For the love of god I cannot figure why can it return ValueError: list.remove(x): x not in list, however considering it's not in the list, somehow, anymore we can just not care about it I guess pass @@ -92,7 +96,8 @@ messagequeue = MessageQueue() async def send_to_discord(msg): - webhooks = msg.webhook_url.copy() - for webhook in webhooks: - msg.webhook_url = [webhook] - messagequeue.add_message(msg) + messagequeue.add_message(msg) + # webhooks = msg.webhook_url.copy() + # for webhook in webhooks: + # msg.webhook_url = [webhook] # Doing it just so it doesn't store reference but value + # messagequeue.add_message(msg.copy())