mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Added code
This commit is contained in:
parent
19730dfcdb
commit
33a317145e
BIN
locale/de/LC_MESSAGES/discussions.mo
Normal file
BIN
locale/de/LC_MESSAGES/discussions.mo
Normal file
Binary file not shown.
105
locale/de/LC_MESSAGES/discussions.po
Normal file
105
locale/de/LC_MESSAGES/discussions.po
Normal file
|
@ -0,0 +1,105 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-04 00:58+0200\n"
|
||||
"PO-Revision-Date: 2020-07-04 01:04+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: discussions.py:56
|
||||
#, python-brace-format
|
||||
msgid "Replied to \"{title}\""
|
||||
msgstr "Antwortete auf „{title}“"
|
||||
|
||||
#: discussions.py:63 discussions.py:79 discussions.py:127 discussions.py:143
|
||||
msgid "unknown"
|
||||
msgstr "Unbekannt"
|
||||
|
||||
#: discussions.py:68
|
||||
#, python-brace-format
|
||||
msgid "Replied to \"{title}\" on {user}'s Message Wall"
|
||||
msgstr "Antwortete auf „{title}“ auf der Nachrichtenseite von {user}"
|
||||
|
||||
#: discussions.py:72
|
||||
#, python-brace-format
|
||||
msgid "Created \"{title}\""
|
||||
msgstr "Erstellte „{title}“"
|
||||
|
||||
#: discussions.py:86
|
||||
#, python-brace-format
|
||||
msgid "Created \"{title}\" on {user}'s Message Wall"
|
||||
msgstr "Erstellte „{title}“ auf der Nachrichtenseite von {user}"
|
||||
|
||||
#: discussions.py:99
|
||||
#, python-brace-format
|
||||
msgid "Created a poll titled \"{title}\""
|
||||
msgstr "Erstellte eine Umfrage „{title}“"
|
||||
|
||||
#: discussions.py:104
|
||||
msgid "Option {}"
|
||||
msgstr "Option {}"
|
||||
|
||||
#: discussions.py:105
|
||||
#, python-brace-format
|
||||
msgid "__[View image]({image_url})__"
|
||||
msgstr "__[Bild öffnen]({image_url})__"
|
||||
|
||||
#: discussions.py:121
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created [{title}](<{url}f/p/{threadId}>) "
|
||||
"in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) erstellte [{title}](<{url}f/p/{threadId}"
|
||||
">) in {forumName}"
|
||||
|
||||
#: discussions.py:130
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}>) on {user}'s Message Wall"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) erstellte [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}>) auf der Nachrichtenseite von "
|
||||
"{user}"
|
||||
|
||||
#: discussions.py:136
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a [reply](<{url}f/p/{threadId}/r/"
|
||||
"{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) erstellte eine [Antwork](<{url}f/p/"
|
||||
"{threadId}/r/{postId}>) zu [{title}](<{url}f/p/{threadId}>) in {forumName}"
|
||||
|
||||
#: discussions.py:147
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) replied to [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}#{replyId}>) on {user}'s Message "
|
||||
"Wall"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) antwortete auf [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}#{replyId}>) auf der "
|
||||
"Nachrichtenseite von {user}"
|
||||
|
||||
#: discussions.py:153
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a poll [{title}](<{url}f/p/"
|
||||
"{threadId}>) in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) erstellte eine Umfrage [{title}](<{url}f/"
|
||||
"p/{threadId}>) in {forumName}"
|
BIN
locale/de/LC_MESSAGES/misc.mo
Normal file
BIN
locale/de/LC_MESSAGES/misc.mo
Normal file
Binary file not shown.
27
locale/de/LC_MESSAGES/misc.po
Normal file
27
locale/de/LC_MESSAGES/misc.po
Normal file
|
@ -0,0 +1,27 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-20 17:18+0200\n"
|
||||
"PO-Revision-Date: 2019-05-20 17:25+0200\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: de\n"
|
||||
|
||||
#: misc.py:76
|
||||
msgid ""
|
||||
"\n"
|
||||
"__And more__"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"__Und mehr__"
|
BIN
locale/de/LC_MESSAGES/rcgcdw.mo
Normal file
BIN
locale/de/LC_MESSAGES/rcgcdw.mo
Normal file
Binary file not shown.
1074
locale/de/LC_MESSAGES/rcgcdw.po
Normal file
1074
locale/de/LC_MESSAGES/rcgcdw.po
Normal file
File diff suppressed because it is too large
Load diff
BIN
locale/en/LC_MESSAGES/discussions.mo
Normal file
BIN
locale/en/LC_MESSAGES/discussions.mo
Normal file
Binary file not shown.
90
locale/en/LC_MESSAGES/discussions.po
Normal file
90
locale/en/LC_MESSAGES/discussions.po
Normal file
|
@ -0,0 +1,90 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-06-23 14:54+0200\n"
|
||||
"PO-Revision-Date: 2020-06-23 14:57+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: discussions.py:56
|
||||
#, python-brace-format
|
||||
msgid "Replied to \"{title}\""
|
||||
msgstr "Replied to \"{title}\""
|
||||
|
||||
#: discussions.py:63 discussions.py:79
|
||||
msgid "unknown"
|
||||
msgstr "unknown"
|
||||
|
||||
#: discussions.py:68
|
||||
#, python-brace-format
|
||||
msgid "Replied to \"{title}\" on {user}'s Message Wall"
|
||||
msgstr "Replied to \"{title}\" on {user}'s Message Wall"
|
||||
|
||||
#: discussions.py:72
|
||||
#, python-brace-format
|
||||
msgid "Created \"{title}\""
|
||||
msgstr "Created \"{title}\""
|
||||
|
||||
#: discussions.py:86
|
||||
#, python-brace-format
|
||||
msgid "Created \"{title}\" on {user}'s Message Wall"
|
||||
msgstr "Created \"{title}\" on {user}'s Message Wall"
|
||||
|
||||
#: discussions.py:99
|
||||
#, python-brace-format
|
||||
msgid "Created a poll titled \"{title}\""
|
||||
msgstr "Created a poll titled \"{title}\""
|
||||
|
||||
#: discussions.py:104
|
||||
msgid "Option {}"
|
||||
msgstr "Option {}"
|
||||
|
||||
#: discussions.py:105
|
||||
#, python-brace-format
|
||||
msgid "__[View image]({image_url})__"
|
||||
msgstr "__[View image]({image_url})__"
|
||||
|
||||
#: discussions.py:118
|
||||
#, python-brace-format
|
||||
#| msgid ""
|
||||
#| "[{author}](<{url}f/u/{creatorId}>) created [{title}](<{url}f/p/{threadId}"
|
||||
#| ">) in ${forumName}"
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created [{title}](<{url}f/p/{threadId}>) "
|
||||
"in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created [{title}](<{url}f/p/{threadId}>) "
|
||||
"in {forumName}"
|
||||
|
||||
#: discussions.py:121
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a [reply](<{url}f/p/{threadId}/r/"
|
||||
"{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a [reply](<{url}f/p/{threadId}/r/"
|
||||
"{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}"
|
||||
|
||||
#: discussions.py:126
|
||||
#, python-brace-format
|
||||
#| msgid ""
|
||||
#| "[{author}](<{url}f/u/{creatorId}>) created [{title}](<{url}f/p/{threadId}"
|
||||
#| ">) in ${forumName}"
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a poll [{title}](<{url}f/p/"
|
||||
"{threadId}>) in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a poll [{title}](<{url}f/p/"
|
||||
"{threadId}>) in {forumName}"
|
BIN
locale/en/LC_MESSAGES/misc.mo
Normal file
BIN
locale/en/LC_MESSAGES/misc.mo
Normal file
Binary file not shown.
27
locale/en/LC_MESSAGES/misc.po
Normal file
27
locale/en/LC_MESSAGES/misc.po
Normal file
|
@ -0,0 +1,27 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-20 17:18+0200\n"
|
||||
"PO-Revision-Date: 2019-05-20 17:32+0200\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: en\n"
|
||||
|
||||
#: misc.py:76
|
||||
msgid ""
|
||||
"\n"
|
||||
"__And more__"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"__And more__"
|
BIN
locale/en/LC_MESSAGES/rcgcdw.mo
Normal file
BIN
locale/en/LC_MESSAGES/rcgcdw.mo
Normal file
Binary file not shown.
1073
locale/en/LC_MESSAGES/rcgcdw.po
Normal file
1073
locale/en/LC_MESSAGES/rcgcdw.po
Normal file
File diff suppressed because it is too large
Load diff
BIN
locale/pl/LC_MESSAGES/discussions.mo
Normal file
BIN
locale/pl/LC_MESSAGES/discussions.mo
Normal file
Binary file not shown.
110
locale/pl/LC_MESSAGES/discussions.po
Normal file
110
locale/pl/LC_MESSAGES/discussions.po
Normal file
|
@ -0,0 +1,110 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-07-04 00:58+0200\n"
|
||||
"PO-Revision-Date: 2020-07-04 01:12+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: pl\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 "
|
||||
"|| n%100>14) ? 1 : 2);\n"
|
||||
|
||||
#: discussions.py:56
|
||||
#, python-brace-format
|
||||
msgid "Replied to \"{title}\""
|
||||
msgstr "Odpowiedział(a) w „{title}”"
|
||||
|
||||
#: discussions.py:63 discussions.py:79 discussions.py:127 discussions.py:143
|
||||
msgid "unknown"
|
||||
msgstr "nieznany"
|
||||
|
||||
#: discussions.py:68
|
||||
#, python-brace-format
|
||||
msgid "Replied to \"{title}\" on {user}'s Message Wall"
|
||||
msgstr ""
|
||||
"Odpowiedział(a) na „{title}” z tablicy wiadomości użytkownika/użytkowniczki "
|
||||
"{user}"
|
||||
|
||||
#: discussions.py:72
|
||||
#, python-brace-format
|
||||
msgid "Created \"{title}\""
|
||||
msgstr "Utworzył(a) „{title}”"
|
||||
|
||||
#: discussions.py:86
|
||||
#, python-brace-format
|
||||
msgid "Created \"{title}\" on {user}'s Message Wall"
|
||||
msgstr ""
|
||||
"Utworzył(a) „{title}” na tablicy wiadomości użytkownika/użytkowniczki {user}"
|
||||
|
||||
#: discussions.py:99
|
||||
#, python-brace-format
|
||||
msgid "Created a poll titled \"{title}\""
|
||||
msgstr "Utworzył(a) ankietę zatytułowaną „{title}”"
|
||||
|
||||
#: discussions.py:104
|
||||
msgid "Option {}"
|
||||
msgstr "Opcja {}"
|
||||
|
||||
#: discussions.py:105
|
||||
#, python-brace-format
|
||||
msgid "__[View image]({image_url})__"
|
||||
msgstr "__[Zobacz zdjęcie]({image_url})__"
|
||||
|
||||
#: discussions.py:121
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created [{title}](<{url}f/p/{threadId}>) "
|
||||
"in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) utworzył(a) [{title}](<{url}f/p/{threadId}"
|
||||
">) w {forumName}"
|
||||
|
||||
#: discussions.py:130
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}>) on {user}'s Message Wall"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) utworzył(a) [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}>) na tablicy wiadomości "
|
||||
"użytkownika/użytkowniczki {user}"
|
||||
|
||||
#: discussions.py:136
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a [reply](<{url}f/p/{threadId}/r/"
|
||||
"{postId}>) to [{title}](<{url}f/p/{threadId}>) in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) utworzył(a) [odpowiedź](<{url}f/p/"
|
||||
"{threadId}/r/{postId}>) pod tematem [{title}](<{url}f/p/{threadId}>) w "
|
||||
"{forumName}"
|
||||
|
||||
#: discussions.py:147
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) replied to [{title}](<{wikiurl}wiki/"
|
||||
"Message_Wall:{user_wall}?threadId={threadid}#{replyId}>) on {user}'s Message "
|
||||
"Wall"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) odpowiedział(a) na[{title}](<{wikiurl}"
|
||||
"wiki/Message_Wall:{user_wall}?threadId={threadid}#{replyId}>) na tablicy "
|
||||
"wiadomości użytkownika/użytkowniczki {user}"
|
||||
|
||||
#: discussions.py:153
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) created a poll [{title}](<{url}f/p/"
|
||||
"{threadId}>) in {forumName}"
|
||||
msgstr ""
|
||||
"[{author}](<{url}f/u/{creatorId}>) utworzył(a) ankietę [{title}](<{url}f/p/"
|
||||
"{threadId}>) w {forumName}"
|
BIN
locale/pl/LC_MESSAGES/misc.mo
Normal file
BIN
locale/pl/LC_MESSAGES/misc.mo
Normal file
Binary file not shown.
27
locale/pl/LC_MESSAGES/misc.po
Normal file
27
locale/pl/LC_MESSAGES/misc.po
Normal file
|
@ -0,0 +1,27 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-05-20 17:18+0200\n"
|
||||
"PO-Revision-Date: 2019-05-20 17:23+0200\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
|
||||
"Language: pl\n"
|
||||
|
||||
#: misc.py:76
|
||||
msgid ""
|
||||
"\n"
|
||||
"__And more__"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"__Oraz więcej__"
|
BIN
locale/pl/LC_MESSAGES/rcgcdw.mo
Normal file
BIN
locale/pl/LC_MESSAGES/rcgcdw.mo
Normal file
Binary file not shown.
1128
locale/pl/LC_MESSAGES/rcgcdw.po
Normal file
1128
locale/pl/LC_MESSAGES/rcgcdw.po
Normal file
File diff suppressed because it is too large
Load diff
40
src/bot.py
40
src/bot.py
|
@ -5,6 +5,7 @@ from src.wiki import Wiki, process_cats, process_mwmsgs, essential_info
|
|||
import asyncio, aiohttp
|
||||
from src.exceptions import *
|
||||
from src.database import db_cursor
|
||||
from collections import defaultdict
|
||||
from queue_handler import DBHandler
|
||||
|
||||
logging.config.dictConfig(settings["logging"])
|
||||
|
@ -19,11 +20,12 @@ mw_msgs: dict = {} # will have the type of id: tuple
|
|||
# Reasons for this: 1. we require amount of wikis to calculate the cooldown between requests
|
||||
# 2. Easier to code
|
||||
|
||||
for wiki in db_cursor.execute('SELECT ROWID, * FROM rcgcdw'):
|
||||
all_wikis[wiki[0]] = Wiki()
|
||||
for wiki in db_cursor.execute('SELECT DISTINCT wiki FROM rcgcdw'):
|
||||
all_wikis[wiki] = Wiki()
|
||||
|
||||
# Start queueing logic
|
||||
|
||||
|
||||
def calculate_delay() -> float:
|
||||
min_delay = 60/settings["max_requests_per_minute"]
|
||||
if (len(all_wikis) * min_delay) < settings["minimal_cooldown_per_wiki_in_sec"]:
|
||||
|
@ -31,20 +33,30 @@ def calculate_delay() -> float:
|
|||
else:
|
||||
return min_delay
|
||||
|
||||
|
||||
def generate_targets(wiki_url: str) -> defaultdict[list]:
|
||||
combinations = defaultdict(list)
|
||||
for webhook in db_cursor.execute('SELECT ROWID, * FROM rcgcdw WHERE wiki = ?', wiki_url):
|
||||
# rowid, guild, configid, webhook, wiki, lang, display, rcid, wikiid, postid
|
||||
combination = (webhook[5], webhook[6]) # lang, display
|
||||
combinations[combination].append(webhook[3])
|
||||
return combinations
|
||||
|
||||
|
||||
async def wiki_scanner():
|
||||
calc_delay = calculate_delay()
|
||||
|
||||
for db_wiki in db_cursor.execute('SELECT ROWID, * FROM rcgcdw'):
|
||||
# db_cursor.execute('SELECT DISTINCT wiki FROM rcgcdw'):
|
||||
for db_wiki in db_cursor.execute('SELECT * FROM rcgcdw GROUP BY wiki'):
|
||||
extended = False
|
||||
if wiki[0] not in all_wikis:
|
||||
if db_wiki[3] not in all_wikis:
|
||||
logger.debug("New wiki: {}".format(wiki[1]))
|
||||
all_wikis[wiki[0]] = Wiki()
|
||||
local_wiki = all_wikis[wiki[0]] # set a reference to a wiki object from memory
|
||||
all_wikis[db_wiki[3]] = Wiki()
|
||||
local_wiki = all_wikis[db_wiki[3]] # set a reference to a wiki object from memory
|
||||
if local_wiki.mw_messages is None:
|
||||
extended = True
|
||||
try:
|
||||
wiki_response = await local_wiki.fetch_wiki(extended, db_wiki[4])
|
||||
await local_wiki.check_status(wiki[0], wiki_response.status, db_wiki[1])
|
||||
wiki_response = await local_wiki.fetch_wiki(extended, db_wiki[0])
|
||||
await local_wiki.check_status(wiki[3], wiki_response.status)
|
||||
except (WikiServerError, WikiError):
|
||||
continue # ignore this wiki if it throws errors
|
||||
try:
|
||||
|
@ -55,19 +67,21 @@ async def wiki_scanner():
|
|||
continue
|
||||
if extended:
|
||||
await process_mwmsgs(recent_changes_resp, local_wiki, mw_msgs)
|
||||
categorize_events = {}
|
||||
if db_wiki[7] is None: # new wiki, just get the last rc to not spam the channel
|
||||
if db_wiki[6] is None: # new wiki, just get the last rc to not spam the channel
|
||||
if len(recent_changes) > 0:
|
||||
DBHandler.add(db_wiki[0], recent_changes[-1]["rcid"])
|
||||
continue
|
||||
else:
|
||||
DBHandler.add(db_wiki[0], 0)
|
||||
continue
|
||||
categorize_events = {}
|
||||
targets = generate_targets(db_wiki[0])
|
||||
for change in recent_changes:
|
||||
await process_cats(change, local_wiki, mw_msgs, categorize_events)
|
||||
for change in recent_changes: # Yeah, second loop since the categories require to be all loaded up
|
||||
if change["rcid"] < db_wiki[7]:
|
||||
await essential_info(change, categorize_events, local_wiki, db_wiki)
|
||||
if change["rcid"] < db_wiki[6]:
|
||||
for target in targets.items():
|
||||
await essential_info(change, categorize_events, local_wiki, db_wiki, target)
|
||||
|
||||
|
||||
await asyncio.sleep(delay=calc_delay)
|
||||
|
|
|
@ -20,7 +20,7 @@ from src.i18n import langs
|
|||
logger = logging.getLogger("rcgcdw.rc_formatters")
|
||||
#from src.rcgcdw import recent_changes, ngettext, logger, profile_field_name, LinkParser, pull_comment
|
||||
|
||||
def compact_formatter(action, change, parsed_comment, categories, recent_changes):
|
||||
def compact_formatter(action, change, parsed_comment, categories, recent_changes, _):
|
||||
LinkParser = LinkParser("domain")
|
||||
if action != "suppressed":
|
||||
author_url = link_formatter(create_article_path("User:{user}".format(user=change["user"])))
|
||||
|
@ -309,7 +309,7 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
|
|||
send_to_discord(DiscordMessage("compact", action, settings["webhookURL"], content=content))
|
||||
|
||||
|
||||
def embed_formatter(action, change, parsed_comment, categories, recent_changes):
|
||||
def embed_formatter(action, change, parsed_comment, categories, recent_changes, _):
|
||||
LinkParser = LinkParser()
|
||||
embed = DiscordMessage("embed", action, settings["webhookURL"])
|
||||
WIKI_API_PATH =
|
||||
|
|
14
src/i18n.py
14
src/i18n.py
|
@ -3,13 +3,13 @@ import sys, logging, gettext
|
|||
logger = logging.getLogger("rcgcdb.i18n")
|
||||
|
||||
try:
|
||||
en = gettext.translation('rcgcdb', localedir='locale', languages=["en"])
|
||||
de = gettext.translation('rcgcdb', localedir='locale', languages=["de"])
|
||||
pl = gettext.translation('rcgcdb', localedir='locale', languages=["pl"])
|
||||
pt = gettext.translation('rcgcdb', localedir='locale', languages=["pt"])
|
||||
ru = gettext.translation('rcgcdb', localedir='locale', languages=["ru"])
|
||||
uk = gettext.translation('rcgcdb', localedir='locale', languages=["uk"])
|
||||
fr = gettext.translation('rcgcdb', localedir='locale', languages=["fr"])
|
||||
en = gettext.translation('rcgcdw', localedir='locale', languages=["en"])
|
||||
de = gettext.translation('rcgcdw', localedir='locale', languages=["de"])
|
||||
pl = gettext.translation('rcgcdw', localedir='locale', languages=["pl"])
|
||||
pt = gettext.translation('rcgcdw', localedir='locale', languages=["pt-br"])
|
||||
ru = gettext.translation('rcgcdw', localedir='locale', languages=["ru"])
|
||||
uk = gettext.translation('rcgcdw', localedir='locale', languages=["uk"])
|
||||
fr = gettext.translation('rcgcdw', localedir='locale', languages=["fr"])
|
||||
langs = {"en": en, "de": de, "pl": pl, "pt": pt, "ru": ru, "uk": uk, "fr": fr}
|
||||
except FileNotFoundError:
|
||||
logger.critical("No language files have been found. Make sure locale folder is located in the directory.")
|
||||
|
|
80
src/misc.py
80
src/misc.py
|
@ -205,43 +205,43 @@ class ContentParser(HTMLParser):
|
|||
self.current_tag = ""
|
||||
|
||||
|
||||
class RecentChangesClass():
|
||||
"""Store verious data and functions related to wiki and fetching of Recent Changes"""
|
||||
def __init__(self):
|
||||
self.tags = {}
|
||||
self.mw_messages = {}
|
||||
self.namespaces = None
|
||||
self.session = session
|
||||
|
||||
@staticmethod
|
||||
def handle_mw_errors(request):
|
||||
if "errors" in request:
|
||||
logger.error(request["errors"])
|
||||
raise MWError
|
||||
return request
|
||||
|
||||
def safe_request(self, url):
|
||||
try:
|
||||
request = self.session.get(url, timeout=10, allow_redirects=False)
|
||||
except requests.exceptions.Timeout:
|
||||
logger.warning("Reached timeout error for request on link {url}".format(url=url))
|
||||
self.downtime_controller()
|
||||
return None
|
||||
except requests.exceptions.ConnectionError:
|
||||
logger.warning("Reached connection error for request on link {url}".format(url=url))
|
||||
self.downtime_controller()
|
||||
return None
|
||||
except requests.exceptions.ChunkedEncodingError:
|
||||
logger.warning("Detected faulty response from the web server for request on link {url}".format(url=url))
|
||||
self.downtime_controller()
|
||||
return None
|
||||
else:
|
||||
if 499 < request.status_code < 600:
|
||||
self.downtime_controller()
|
||||
return None
|
||||
elif request.status_code == 302:
|
||||
logger.warning("Redirect detected! Either the wiki given in the script settings (wiki field) is incorrect/the wiki got removed or Gamepedia is giving us the false value. Please provide the real URL to the wiki, current URL redirects to {}".format(request.next.url))
|
||||
return request
|
||||
|
||||
def init_info(self):
|
||||
return
|
||||
# class RecentChangesClass():
|
||||
# """Store verious data and functions related to wiki and fetching of Recent Changes"""
|
||||
# def __init__(self):
|
||||
# self.tags = {}
|
||||
# self.mw_messages = {}
|
||||
# self.namespaces = None
|
||||
# self.session = session
|
||||
#
|
||||
# @staticmethod
|
||||
# def handle_mw_errors(request):
|
||||
# if "errors" in request:
|
||||
# logger.error(request["errors"])
|
||||
# raise MWError
|
||||
# return request
|
||||
#
|
||||
# def safe_request(self, url):
|
||||
# try:
|
||||
# request = self.session.get(url, timeout=10, allow_redirects=False)
|
||||
# except requests.exceptions.Timeout:
|
||||
# logger.warning("Reached timeout error for request on link {url}".format(url=url))
|
||||
# self.downtime_controller()
|
||||
# return None
|
||||
# except requests.exceptions.ConnectionError:
|
||||
# logger.warning("Reached connection error for request on link {url}".format(url=url))
|
||||
# self.downtime_controller()
|
||||
# return None
|
||||
# except requests.exceptions.ChunkedEncodingError:
|
||||
# logger.warning("Detected faulty response from the web server for request on link {url}".format(url=url))
|
||||
# self.downtime_controller()
|
||||
# return None
|
||||
# else:
|
||||
# if 499 < request.status_code < 600:
|
||||
# self.downtime_controller()
|
||||
# return None
|
||||
# elif request.status_code == 302:
|
||||
# logger.warning("Redirect detected! Either the wiki given in the script settings (wiki field) is incorrect/the wiki got removed or Gamepedia is giving us the false value. Please provide the real URL to the wiki, current URL redirects to {}".format(request.next.url))
|
||||
# return request
|
||||
#
|
||||
# def init_info(self):
|
||||
# return
|
28
src/wiki.py
28
src/wiki.py
|
@ -44,25 +44,25 @@ class Wiki:
|
|||
raise WikiServerError
|
||||
return response
|
||||
|
||||
async def check_status(self, wiki_id, status, name):
|
||||
async def check_status(self, wiki_url, status):
|
||||
if 199 < status < 300:
|
||||
self.fail_times = 0
|
||||
pass
|
||||
elif 400 < status < 500: # ignore 400 error since this might be our fault
|
||||
self.fail_times += 1
|
||||
logger.warning("Wiki {} responded with HTTP code {}, increased fail_times to {}, skipping...".format(name, status, self.fail_times))
|
||||
logger.warning("Wiki {} responded with HTTP code {}, increased fail_times to {}, skipping...".format(wiki_url, status, self.fail_times))
|
||||
if self.fail_times > 3:
|
||||
await self.remove(wiki_id, status)
|
||||
await self.remove(wiki_url, status)
|
||||
raise WikiError
|
||||
elif 499 < status < 600:
|
||||
logger.warning("Wiki {} responded with HTTP code {}, skipping...".format(name, status, self.fail_times))
|
||||
logger.warning("Wiki {} responded with HTTP code {}, skipping...".format(wiki_url, status, self.fail_times))
|
||||
raise WikiServerError
|
||||
|
||||
async def remove(self, wiki_id, reason):
|
||||
src.discord.wiki_removal(wiki_id, reason)
|
||||
src.discord.wiki_removal_monitor(wiki_id, reason)
|
||||
db_cursor.execute("DELETE FROM observers WHERE wiki_id = ?", wiki_id)
|
||||
db_cursor.execute("DELETE FROM wikis WHERE ROWID = ?", wiki_id)
|
||||
db_cursor.execute("DELETE FROM rcgcdw WHERE wiki = ?", wiki_id)
|
||||
logger.warning("{} rows affected by DELETE FROM rcgcdw WHERE wiki = {}".format(db_cursor.rowcount, wiki_id))
|
||||
db_connection.commit()
|
||||
|
||||
|
||||
|
@ -118,20 +118,24 @@ async def process_mwmsgs(wiki_response: dict, local_wiki: Wiki, mw_msgs: dict):
|
|||
if msgs == set:
|
||||
local_wiki.mw_messages = key
|
||||
return
|
||||
# if same entry is not in mw_msgs
|
||||
key = len(mw_msgs)
|
||||
mw_msgs[key] = msgs # it may be a little bit messy for sure, however I don't expect any reason to remove mw_msgs entries by one
|
||||
local_wiki.mw_messages = key
|
||||
|
||||
async def essential_info(change, changed_categories, local_wiki, db_wiki):
|
||||
async def essential_info(change: dict, changed_categories, local_wiki: Wiki, db_wiki: tuple, target: tuple):
|
||||
"""Prepares essential information for both embed and compact message format."""
|
||||
recent_changes = RecentChangesClass()
|
||||
def _(string: str) -> str:
|
||||
"""Our own translation string to make it compatible with async"""
|
||||
return lang.gettext(string)
|
||||
recent_changes = RecentChangesClass() # TODO Look into replacing RecentChangesClass with local_wiki
|
||||
LinkParser = LinkParser("domain")
|
||||
logger.debug(change)
|
||||
lang = langs[db_wiki[1]]
|
||||
appearance_mode = embed_formatter # TODO Add chanding depending on the DB entry
|
||||
appearance_mode = embed_formatter if target[0][1] > 0 else compact_formatter
|
||||
if ("actionhidden" in change or "suppressed" in change): # if event is hidden using suppression
|
||||
appearance_mode("suppressed", change, "", changed_categories, recent_changes)
|
||||
appearance_mode("suppressed", change, "", changed_categories, recent_changes, target, _)
|
||||
return
|
||||
lang = langs[target[0][0]]
|
||||
if "commenthidden" not in change:
|
||||
LinkParser.feed(change["parsedcomment"])
|
||||
parsed_comment = LinkParser.new_string
|
||||
|
@ -158,4 +162,4 @@ async def essential_info(change, changed_categories, local_wiki, db_wiki):
|
|||
else:
|
||||
logger.warning("This event is not implemented in the script. Please make an issue on the tracker attaching the following info: wiki url, time, and this information: {}".format(change))
|
||||
return
|
||||
appearance_mode(identification_string, change, parsed_comment, changed_categories, recent_changes)
|
||||
appearance_mode(identification_string, change, parsed_comment, changed_categories, recent_changes, target, _)
|
||||
|
|
Loading…
Reference in a new issue