diff --git a/locale/de/LC_MESSAGES/discord.mo b/locale/de/LC_MESSAGES/discord.mo index 5704f08..0f0814e 100644 Binary files a/locale/de/LC_MESSAGES/discord.mo and b/locale/de/LC_MESSAGES/discord.mo differ 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 \n" "Language-Team: Polish \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 85bc5e4..15b2e7d 100644 Binary files a/locale/widgets/de.png and b/locale/widgets/de.png differ diff --git a/locale/widgets/hi.png b/locale/widgets/hi.png index 85bc5e4..ff18351 100644 Binary files a/locale/widgets/hi.png and b/locale/widgets/hi.png differ diff --git a/locale/widgets/pl.png b/locale/widgets/pl.png index ac4faba..6479dd4 100644 Binary files a/locale/widgets/pl.png and b/locale/widgets/pl.png differ diff --git a/locale/widgets/pt-br.png b/locale/widgets/pt-br.png index 0bf7cc0..6479dd4 100644 Binary files a/locale/widgets/pt-br.png and b/locale/widgets/pt-br.png differ diff --git a/locale/widgets/ru.png b/locale/widgets/ru.png index 4e01f34..2e9e3ec 100644 Binary files a/locale/widgets/ru.png and b/locale/widgets/ru.png differ diff --git a/locale/widgets/zh-hans.png b/locale/widgets/zh-hans.png index 13b96fe..4ebe20d 100644 Binary files a/locale/widgets/zh-hans.png and b/locale/widgets/zh-hans.png differ 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())