From 68a3f8466760540a1878ae9b9c746c0a9ff73f0c Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 16 Jun 2018 14:55:51 +0200 Subject: [PATCH] Small changes --- locale/pl/LC_MESSAGES/rcgcdw.mo | Bin 5367 -> 5351 bytes locale/pl/LC_MESSAGES/rcgcdw.po | 138 ++++++++++++++++---------------- rcgcdw.pot | 122 ++++++++++++++-------------- rcgcdw.py | 110 ++++++++++++------------- 4 files changed, 188 insertions(+), 182 deletions(-) diff --git a/locale/pl/LC_MESSAGES/rcgcdw.mo b/locale/pl/LC_MESSAGES/rcgcdw.mo index 9cd2b8a52b8b6f4c1e8edd58e9c1faf9b5cbc0a9..85660d5475c6571e1dfa1b3291e35703f5e1a085 100644 GIT binary patch delta 1062 zcmX}qJ7`l;9LMn!lGZ%i#>Q7$HEk1ZjCq*cKD<^PsvsqZh>MGo*fbQi=ujVsWauJP z!Ezm3L=nM395mo$hk{}q?dIqpogActicn{c{S&tiu94))?3OyVl;#h=)L@t~=j zI2XB~F$Fw@gE)_B=s9l2Rn&*Rq89RmjA_FFs^L!T#vJ-^0@c_FjAI40@I1cu81n-6 zQ=f~}n=dXzjOpjbV{FG|?7|gH;AhkyY_v?!z7m+kEm%Q4ccWE5LN(OD)A*rP_Yj{& zoy8%%Q0GDq-bHoz1b5*I?!h%YiXC*L1y7=qnZ{9EL?!YO^+%sDj~l3ka?$2@rf{5k z0hRO$ZpZp>E_l|&$ayO!u@A>l5uZgxc^OKmI=`Ct>!yphIA3NM75x#^0>_bUGF8-`Ud0}~hH7N7kXG=p#Ym9RK+_+Te<0)pGsbMj-6=@X=?Ux#3E8WQ188^ydJjl#2wFL*5^yCgD zp%HFkMo_Wq2i)Pz`Fi_xvXqH(Qr1M{4z|XOF|*DqU$4_N{sr)vZiWB= delta 1076 zcmZ9~Pe_w-9LMpW?s3`vl;*$8{>)9wsnh+@<(A+*i$bI>feqbcT0<(yAlR{B!&Jgpxlk?+hbp^o4ZYJ(DTT;>*9_yBj|I;xS^$dNj~@qIbzfzyoE z)6fxVXdewlzlS--{wAh73@xe!^&M!8GSz@$)d({KOpeltoRe|hEQx8RQiw3)OnP#L zj#R@}#W^yiJy5HSy=--LD<@^HFH0E{jWakSlVT3r>sCu$$bMmk8iLf(%6IFq%bzb~ zXU}DF7Xl~qi+THsH&{tF9(CFGy=g0vPQ>kR-k#1xdUR|c8jnUjM>2)^<;;9GGM&ww nO$Y2bU)k>P#q3RA*7xtXbYSUB<&^*S|7$;Q?XCQ7dgl5IMPGGK diff --git a/locale/pl/LC_MESSAGES/rcgcdw.po b/locale/pl/LC_MESSAGES/rcgcdw.po index a3bb240..c6cfdaf 100644 --- a/locale/pl/LC_MESSAGES/rcgcdw.po +++ b/locale/pl/LC_MESSAGES/rcgcdw.po @@ -5,39 +5,40 @@ msgid "" msgstr "" "Project-Id-Version: RcGcDw\n" -"POT-Creation-Date: 2018-06-16 13:32+0200\n" -"PO-Revision-Date: 2018-06-16 13:58+0200\n" +"POT-Creation-Date: 2018-06-16 14:38+0200\n" +"PO-Revision-Date: 2018-06-16 14:44+0200\n" +"Last-Translator: Frisk \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" "Generated-By: pygettext.py 1.5\n" "X-Generator: Poedit 2.0.8\n" -"Last-Translator: Frisk \n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -"Language: pl\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" -#: rcgcdw.py:88 +#: rcgcdw.py:90 msgid "New file version {name}" msgstr "Nowa wersja pliku (name)" -#: rcgcdw.py:89 +#: rcgcdw.py:91 msgid "([preview]({link}) | [undo]({undolink}))" msgstr "([podgląd]({link}) | [wycofaj]({undolink}))" -#: rcgcdw.py:89 rcgcdw.py:105 +#: rcgcdw.py:91 rcgcdw.py:107 msgid "Options" msgstr "Opcje" -#: rcgcdw.py:91 +#: rcgcdw.py:93 msgid "New file {name}" msgstr "Nowy plik {name}" -#: rcgcdw.py:105 +#: rcgcdw.py:107 msgid "([preview]({link}))" msgstr "([podgląd]({link})" -#: rcgcdw.py:106 +#: rcgcdw.py:108 msgid "" "{desc}\n" "License: {license}" @@ -45,206 +46,209 @@ msgstr "" "{desc}\n" "Licencja: {license}" -#: rcgcdw.py:111 +#: rcgcdw.py:113 msgid "Deleted {article}" msgstr "Usunięto {article}" -#: rcgcdw.py:116 +#: rcgcdw.py:118 msgid "Deleted redirect ({article}) to make space for moved page" -msgstr "Usunięto przekierowanie ({article}) aby utworzyć miejsce dla przenoszonej strony" +msgstr "" +"Usunięto przekierowanie ({article}) aby utworzyć miejsce dla przenoszonej " +"strony" -#: rcgcdw.py:120 +#: rcgcdw.py:122 msgid "A redirect has been made" msgstr "Zostało utworzone przekierowanie" -#: rcgcdw.py:120 +#: rcgcdw.py:122 msgid "No redirect has been made" msgstr "Nie utworzono przekierowania" -#: rcgcdw.py:121 +#: rcgcdw.py:123 msgid "Moved \"{article}\" to \"{target}\"" msgstr "Przeniesiono \"{article}\" do \"{target}\"" -#: rcgcdw.py:124 +#: rcgcdw.py:126 msgid "Moved {article} to redirect page ({title})" msgstr "Przeniesiono {article} do przekierowania ({title})" -#: rcgcdw.py:128 +#: rcgcdw.py:130 msgid "Moved protection settings from {article} to {title}" msgstr "Przeniesiono ustawienia zabezpieczeń z {article} do {title}" -#: rcgcdw.py:133 +#: rcgcdw.py:135 msgid "infinity and beyond" msgstr "wieczność" -#: rcgcdw.py:134 +#: rcgcdw.py:136 msgid "Blocked {blocked_user} for {time}" msgstr "Zablokowano {blocked_user} na {time}" -#: rcgcdw.py:140 +#: rcgcdw.py:142 msgid "Reapplied the block on {blocked_user}" msgstr "Ponownie nałożono blokadę na {blocked_user}" -#: rcgcdw.py:146 +#: rcgcdw.py:148 msgid "Removed the block on {blocked_user}" msgstr "Usunięto blokadę na {blocked_user}" -#: rcgcdw.py:151 +#: rcgcdw.py:153 msgid "Left a comment on {target}'s profile" msgstr "Pozostawiono komentarz na profilu użytkownika {target}" -#: rcgcdw.py:154 +#: rcgcdw.py:156 msgid "Replied to a comment on {target}'s profile" msgstr "Odpowiedziano na komentarz na profilu użytkownika {target}" -#: rcgcdw.py:157 +#: rcgcdw.py:159 msgid "Edited a comment on {target}'s profile" msgstr "Edytowano komentarz na profilu użytkownika {target}" -#: rcgcdw.py:161 +#: rcgcdw.py:163 msgid "Location" msgstr "Lokacja" -#: rcgcdw.py:163 +#: rcgcdw.py:165 msgid "About me" msgstr "O mnie" -#: rcgcdw.py:183 +#: rcgcdw.py:185 msgid "Unknown" msgstr "Nieznana" -#: rcgcdw.py:184 +#: rcgcdw.py:186 msgid "Edited {target}'s profile" msgstr "Edytowano profil użytkownika {target}" -#: rcgcdw.py:185 +#: rcgcdw.py:187 msgid "{field} field changed to: {desc}" msgstr "pole {field} zostało zmienione na: {desc}" -#: rcgcdw.py:188 +#: rcgcdw.py:190 msgid "Removed a comment on {target}'s profile" msgstr "Usunięto komentarz na profilu użytkownika {target}" -#: rcgcdw.py:191 +#: rcgcdw.py:193 msgid "Changed {target}'s user groups" msgstr "Zmieniono grupy użytkownika {target}" -#: rcgcdw.py:195 rcgcdw.py:197 +#: rcgcdw.py:197 rcgcdw.py:199 msgid "none" msgstr "brak" -#: rcgcdw.py:198 -msgid "Groups changed from {old_groups} to {new_groups} with reason given: {desc}" +#: rcgcdw.py:200 +msgid "" +"Groups changed from {old_groups} to {new_groups} with reason given: {desc}" msgstr "Grupy zmienione z {old_groups} do {new_groups} z powodu: {desc}" -#: rcgcdw.py:201 +#: rcgcdw.py:203 msgid "Protected the page {target}" msgstr "Zabezpieczono stronę: {target}" -#: rcgcdw.py:206 +#: rcgcdw.py:208 msgid "Modified protection settings for {article}" msgstr "Zmodyfikowano ustawienia zabezpieczeń dla {article}" -#: rcgcdw.py:211 +#: rcgcdw.py:213 msgid "Removed protection for {article}" msgstr "Usunięto zabezpieczenia dla {article}" -#: rcgcdw.py:215 +#: rcgcdw.py:217 msgid "Removed revision(s) from public view for {article}" msgstr "Usunięto edycje z widoku publicznego dla {article}" -#: rcgcdw.py:218 +#: rcgcdw.py:220 msgid "Imported {article} with {count} revision(s)" msgstr "Zaimportowano {article} z {count} wersjami" -#: rcgcdw.py:221 +#: rcgcdw.py:223 msgid "Restored {article}" msgstr "Przywrócono {article)" -#: rcgcdw.py:224 +#: rcgcdw.py:226 msgid "Removed events" msgstr "Usunięto wydarzenia" -#: rcgcdw.py:227 +#: rcgcdw.py:229 msgid "Imported interwiki" msgstr "Zaimportowano interwiki" -#: rcgcdw.py:230 +#: rcgcdw.py:232 msgid "Edited abuse filter number {number}" msgstr "Edytowano filtr nadużyć numer (number)" -#: rcgcdw.py:233 +#: rcgcdw.py:235 msgid "Merged revision histories for {article}" msgstr "Połączono historie artykułu dla {article}" -#: rcgcdw.py:236 +#: rcgcdw.py:238 msgid "Added interwiki entry" msgstr "Dodano intwrwiki" -#: rcgcdw.py:237 rcgcdw.py:241 +#: rcgcdw.py:239 rcgcdw.py:243 msgid "Prefix: {prefix}, website: {website} | {desc}" msgstr "Prefix: {prefix}, strona: {website} | desc" -#: rcgcdw.py:240 +#: rcgcdw.py:242 msgid "Edited interwiki entry" msgstr "Edytowano interwiki" -#: rcgcdw.py:244 +#: rcgcdw.py:246 msgid "Deleted interwiki entry" msgstr "Usunięto interwiki" -#: rcgcdw.py:245 +#: rcgcdw.py:247 msgid "Prefix: {prefix} | {desc}" msgstr "Prefix: {prefix} | {desc}" -#: rcgcdw.py:248 +#: rcgcdw.py:250 msgid "Changed content model of {article}" msgstr "Zmieniono model zawartości {article}" -#: rcgcdw.py:249 +#: rcgcdw.py:251 msgid "Model changed from {old} to {new}: {reason}" msgstr "Model został zmieniony z {old} na {new}: reason" -#: rcgcdw.py:252 +#: rcgcdw.py:254 msgid "Edited the sprite for {article}" msgstr "Edytowano sprite dla {article}" -#: rcgcdw.py:255 +#: rcgcdw.py:257 msgid "Created the sprite sheet for {article}" msgstr "Utworzono sprite sheet dla {article}" -#: rcgcdw.py:258 +#: rcgcdw.py:260 msgid "Edited the slice for {article}" msgstr "Edytowano część sprite dla {article}" -#: rcgcdw.py:261 +#: rcgcdw.py:263 msgid "Created a tag \"{tag}\"" msgstr "Utworzono tag \"{tag}\"" -#: rcgcdw.py:264 +#: rcgcdw.py:266 msgid "Deleted a tag \"{tag}\"" msgstr "Usunięto tag \"{tag}\"" -#: rcgcdw.py:283 +#: rcgcdw.py:285 msgid "No description provided" msgstr "Nie podano opisu zmian" -#: rcgcdw.py:364 +#: rcgcdw.py:366 msgid "Unable to process the event" msgstr "Nie udało się odczytać wydarzenia" -#: rcgcdw.py:364 +#: rcgcdw.py:366 msgid "error" msgstr "błąd" -#: rcgcdw.py:445 +#: rcgcdw.py:451 msgid "Connection status" msgstr "Problem z połączeniem" -#: rcgcdw.py:445 -msgid "Minecraft Wiki seems to be down or unreachable." -msgstr "Minecraft Wiki nie działa lub jest nieosiągalna." - -#: rcgcdw.py:445 +#: rcgcdw.py:451 msgid "https://i.imgur.com/2jWQEt1.png" msgstr "https://i.imgur.com/2jWQEt1.png" + +#: rcgcdw.py:451 +msgid "{wiki} seems to be down or unreachable." +msgstr "{wiki} nie działa lub jest nieosiągalna." diff --git a/rcgcdw.pot b/rcgcdw.pot index 2d1759b..e18f229 100644 --- a/rcgcdw.pot +++ b/rcgcdw.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2018-06-16 13:32+0200\n" +"POT-Creation-Date: 2018-06-16 14:38+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -15,233 +15,233 @@ msgstr "" "Generated-By: pygettext.py 1.5\n" -#: rcgcdw.py:88 +#: rcgcdw.py:90 msgid "New file version {name}" msgstr "" -#: rcgcdw.py:89 +#: rcgcdw.py:91 msgid "([preview]({link}) | [undo]({undolink}))" msgstr "" -#: rcgcdw.py:89 rcgcdw.py:105 +#: rcgcdw.py:91 rcgcdw.py:107 msgid "Options" msgstr "" -#: rcgcdw.py:91 +#: rcgcdw.py:93 msgid "New file {name}" msgstr "" -#: rcgcdw.py:105 +#: rcgcdw.py:107 msgid "([preview]({link}))" msgstr "" -#: rcgcdw.py:106 +#: rcgcdw.py:108 msgid "" "{desc}\n" "License: {license}" msgstr "" -#: rcgcdw.py:111 +#: rcgcdw.py:113 msgid "Deleted {article}" msgstr "" -#: rcgcdw.py:116 +#: rcgcdw.py:118 msgid "Deleted redirect ({article}) to make space for moved page" msgstr "" -#: rcgcdw.py:120 +#: rcgcdw.py:122 msgid "A redirect has been made" msgstr "" -#: rcgcdw.py:120 +#: rcgcdw.py:122 msgid "No redirect has been made" msgstr "" -#: rcgcdw.py:121 +#: rcgcdw.py:123 msgid "Moved \"{article}\" to \"{target}\"" msgstr "" -#: rcgcdw.py:124 +#: rcgcdw.py:126 msgid "Moved {article} to redirect page ({title})" msgstr "" -#: rcgcdw.py:128 +#: rcgcdw.py:130 msgid "Moved protection settings from {article} to {title}" msgstr "" -#: rcgcdw.py:133 +#: rcgcdw.py:135 msgid "infinity and beyond" msgstr "" -#: rcgcdw.py:134 +#: rcgcdw.py:136 msgid "Blocked {blocked_user} for {time}" msgstr "" -#: rcgcdw.py:140 +#: rcgcdw.py:142 msgid "Reapplied the block on {blocked_user}" msgstr "" -#: rcgcdw.py:146 +#: rcgcdw.py:148 msgid "Removed the block on {blocked_user}" msgstr "" -#: rcgcdw.py:151 +#: rcgcdw.py:153 msgid "Left a comment on {target}'s profile" msgstr "" -#: rcgcdw.py:154 +#: rcgcdw.py:156 msgid "Replied to a comment on {target}'s profile" msgstr "" -#: rcgcdw.py:157 +#: rcgcdw.py:159 msgid "Edited a comment on {target}'s profile" msgstr "" -#: rcgcdw.py:161 +#: rcgcdw.py:163 msgid "Location" msgstr "" -#: rcgcdw.py:163 +#: rcgcdw.py:165 msgid "About me" msgstr "" -#: rcgcdw.py:183 +#: rcgcdw.py:185 msgid "Unknown" msgstr "" -#: rcgcdw.py:184 +#: rcgcdw.py:186 msgid "Edited {target}'s profile" msgstr "" -#: rcgcdw.py:185 +#: rcgcdw.py:187 msgid "{field} field changed to: {desc}" msgstr "" -#: rcgcdw.py:188 +#: rcgcdw.py:190 msgid "Removed a comment on {target}'s profile" msgstr "" -#: rcgcdw.py:191 +#: rcgcdw.py:193 msgid "Changed {target}'s user groups" msgstr "" -#: rcgcdw.py:195 rcgcdw.py:197 +#: rcgcdw.py:197 rcgcdw.py:199 msgid "none" msgstr "" -#: rcgcdw.py:198 +#: rcgcdw.py:200 msgid "Groups changed from {old_groups} to {new_groups} with reason given: {desc}" msgstr "" -#: rcgcdw.py:201 +#: rcgcdw.py:203 msgid "Protected the page {target}" msgstr "" -#: rcgcdw.py:206 +#: rcgcdw.py:208 msgid "Modified protection settings for {article}" msgstr "" -#: rcgcdw.py:211 +#: rcgcdw.py:213 msgid "Removed protection for {article}" msgstr "" -#: rcgcdw.py:215 +#: rcgcdw.py:217 msgid "Removed revision(s) from public view for {article}" msgstr "" -#: rcgcdw.py:218 +#: rcgcdw.py:220 msgid "Imported {article} with {count} revision(s)" msgstr "" -#: rcgcdw.py:221 +#: rcgcdw.py:223 msgid "Restored {article}" msgstr "" -#: rcgcdw.py:224 +#: rcgcdw.py:226 msgid "Removed events" msgstr "" -#: rcgcdw.py:227 +#: rcgcdw.py:229 msgid "Imported interwiki" msgstr "" -#: rcgcdw.py:230 +#: rcgcdw.py:232 msgid "Edited abuse filter number {number}" msgstr "" -#: rcgcdw.py:233 +#: rcgcdw.py:235 msgid "Merged revision histories for {article}" msgstr "" -#: rcgcdw.py:236 +#: rcgcdw.py:238 msgid "Added interwiki entry" msgstr "" -#: rcgcdw.py:237 rcgcdw.py:241 +#: rcgcdw.py:239 rcgcdw.py:243 msgid "Prefix: {prefix}, website: {website} | {desc}" msgstr "" -#: rcgcdw.py:240 +#: rcgcdw.py:242 msgid "Edited interwiki entry" msgstr "" -#: rcgcdw.py:244 +#: rcgcdw.py:246 msgid "Deleted interwiki entry" msgstr "" -#: rcgcdw.py:245 +#: rcgcdw.py:247 msgid "Prefix: {prefix} | {desc}" msgstr "" -#: rcgcdw.py:248 +#: rcgcdw.py:250 msgid "Changed content model of {article}" msgstr "" -#: rcgcdw.py:249 +#: rcgcdw.py:251 msgid "Model changed from {old} to {new}: {reason}" msgstr "" -#: rcgcdw.py:252 +#: rcgcdw.py:254 msgid "Edited the sprite for {article}" msgstr "" -#: rcgcdw.py:255 +#: rcgcdw.py:257 msgid "Created the sprite sheet for {article}" msgstr "" -#: rcgcdw.py:258 +#: rcgcdw.py:260 msgid "Edited the slice for {article}" msgstr "" -#: rcgcdw.py:261 +#: rcgcdw.py:263 msgid "Created a tag \"{tag}\"" msgstr "" -#: rcgcdw.py:264 +#: rcgcdw.py:266 msgid "Deleted a tag \"{tag}\"" msgstr "" -#: rcgcdw.py:283 +#: rcgcdw.py:285 msgid "No description provided" msgstr "" -#: rcgcdw.py:364 +#: rcgcdw.py:366 msgid "Unable to process the event" msgstr "" -#: rcgcdw.py:364 +#: rcgcdw.py:366 msgid "error" msgstr "" -#: rcgcdw.py:445 +#: rcgcdw.py:451 msgid "Connection status" msgstr "" -#: rcgcdw.py:445 -msgid "Minecraft Wiki seems to be down or unreachable." -msgstr "" - -#: rcgcdw.py:445 +#: rcgcdw.py:451 msgid "https://i.imgur.com/2jWQEt1.png" msgstr "" +#: rcgcdw.py:451 +msgid "{wiki} seems to be down or unreachable." +msgstr "" + diff --git a/rcgcdw.py b/rcgcdw.py index 4b9c017..4bed649 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import time, logging, json, requests, datetime, re, gettext +import time, logging, json, requests, datetime, re, gettext, math, random from bs4 import BeautifulSoup from collections import defaultdict logging.basicConfig(level=logging.DEBUG) @@ -39,21 +39,21 @@ def webhook_formatter(action, timestamp, **params): embed = defaultdict(dict) if "title" in params: article_encoded = params["title"].replace(" ", "_").replace(')', '\)') - if re.match(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", params["author"]) is not None: - author_url = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"], user=params["author"]) - if params["author"] not in list(recent_changes.map_ips.keys()): - contibs = safe_read(recent_changes.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&list=usercontribs&uclimit=max&ucuser={user}&ucprop=".format(wiki=settings["wiki"], user=params["author"])), "query", "usercontribs") + if re.match(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b", params["user"]) is not None: + author_url = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"], user=params["user"]) + if params["user"] not in list(recent_changes.map_ips.keys()): + contibs = safe_read(recent_changes.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&list=usercontribs&uclimit=max&ucuser={user}&ucprop=".format(wiki=settings["wiki"], user=params["user"])), "query", "usercontribs") if contibs is None: logging.warning("WARNING: Something went wrong when checking amount of contributions for given IP address") - params["author"] = params["author"] + "(?)" + params["user"] = params["user"] + "(?)" else: - params["author"] = "{author} ({contribs})".format(author=params["author"], contribs=len(contibs)) - recent_changes.map_ips[params["author"]]=len(contibs) + params["user"] = "{author} ({contribs})".format(author=params["user"], contribs=len(contibs)) + recent_changes.map_ips[params["user"]]=len(contibs) else: - recent_changes.map_ips[params["author"]]+=1 - params["author"] = "{author} ({amount})".format(author=params["author"], amount=recent_changes.map_ips[params["author"]]) + recent_changes.map_ips[params["user"]]+=1 + params["user"] = "{author} ({amount})".format(author=params["user"], amount=recent_changes.map_ips[params["user"]]) else: - author_url = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=params["author"].replace(" ", "_")) + author_url = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=params["user"].replace(" ", "_")) if action in [1, 37]: #edit or new page editsize = params["size"] if editsize > 0: @@ -69,12 +69,12 @@ def webhook_formatter(action, timestamp, **params): elif editsize == 0: colornumber = 8750469 link = "https://{wiki}.gamepedia.com/index.php?title={article}&curid={pageid}&diff={diff}&oldid={oldrev}".format(wiki=settings["wiki"], pageid=params["pageid"], diff=params["diff"], oldrev=params["oldrev"], article=article_encoded) - if event == "edit": + if action == 1: embed["author"]["icon_url"] = "https://d1u5p3l4wpay3k.cloudfront.net/minecraft_pl_gamepedia/d/df/Ksi%C4%85%C5%BCka_z_pi%C3%B3rem.png?version=d2b085f15fb5713091ed06f92f81c360" else: embed["author"]["icon_url"] = "https://framapic.org/VBVcOznftNsV/4a0fbBL7wkUo.png" - embed["title"] = "{article} ({new}{minor}{editsize})".format(article=params["title"], editsize="+"+str(editsize) if editsize>0 else editsize, new= "(N!) " if event == 37 else "", minor="m " if event == "edit" and params["minor"] else "") - elif event == 5: #sending files + embed["title"] = "{article} ({new}{minor}{editsize})".format(article=params["title"], editsize="+"+str(editsize) if editsize>0 else editsize, new= "(N!) " if action == 37 else "", minor="m " if action == 1 and params["minor"] else "") + elif action == 5: #sending files urls = safe_read(recent_changes.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&prop=imageinfo&list=&meta=&titles={filename}&iiprop=timestamp%7Curl&iilimit=2".format(wiki=settings["wiki"], filename=params["title"])), "query", "pages") undolink = "" link ="https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) @@ -91,7 +91,7 @@ def webhook_formatter(action, timestamp, **params): embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}) | [undo]({undolink}))").format(link=embed["image"]["url"], undolink=undolink)}] else: embed["title"] = _("New file {name}").format(name=params["title"]) - article_content = safe_read(recent_changes.safe_request("https://minecraft.gamepedia.com/api.php?action=query&format=json&prop=revisions&titles={article}&rvprop=content".format(article=urllib.parse.quote_plus(params["title"]))), "query", "pages") #TODO Napewno urllib? + article_content = safe_read(recent_changes.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&prop=revisions&titles={article}&rvprop=content".format(wiki=settings["wiki"], article=urllib.parse.quote_plus(params["title"]))), "query", "pages") #TODO Napewno urllib? if article_content is None: logging.warning("Something went wrong when getting license for the image") return 0 @@ -106,58 +106,58 @@ def webhook_formatter(action, timestamp, **params): license = "?" embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}))").format(link=pic_url)}] params["desc"] = _("{desc}\nLicense: {license}").format(desc=params["desc"], license=license) - elif event == 6: + elif action == 6: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["author"]["icon_url"] = "https://framapic.org/9Rgw6Vkx1L1b/R9WrMWJ6umeX.png" colornumber = 1 embed["title"] = _("Deleted {article}").format(article=params["title"]) - elif event == 7: + elif action == 7: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["author"]["icon_url"] = "https://framapic.org/9Rgw6Vkx1L1b/R9WrMWJ6umeX.png" colornumber = 1 embed["title"] = _("Deleted redirect ({article}) to make space for moved page").format(article=params["title"]) - elif event == 14: + elif action == 14: link = params["targetlink"] embed["author"]["icon_url"] = "https://i.imgur.com/ZX02KBf.png" params["desc"] = "{supress}. {desc}".format(desc=params["desc"], supress=_("No redirect has been made") if params["supress"] == True else _("A redirect has been made")) embed["title"] = _("Moved \"{article}\" to \"{target}\"").format(article = params["title"], target=params["target"]) - elif event == 15: + elif action == 15: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Moved {article} to redirect page ({title})").format(article=params["title"], title=params["target"]) embed["author"]["icon_url"]= "https://i.imgur.com/ZX02KBf.png" - elif event == 16: + elif action == 16: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Moved protection settings from {article} to {title}").format(article=params["title"], title=params["target"]) embed["author"]["icon_url"]= "https://i.imgur.com/ZX02KBf.png" - elif event == 17: + elif action == 17: link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"], user=params["blocked_user"].replace(" ", "_").replace(')', '\)')) user = params["blocked_user"].split(':')[1] time =_( "infinity and beyond") if params["duration"] == "infinite" else params["duration"] - embed["title"] = _("Blocked {blocked_user} for {time}").format(blocked_user=user, time=duration) + embed["title"] = _("Blocked {blocked_user} for {time}").format(blocked_user=user, time=time) colornumber = 1 embed["author"]["icon_url"] = "https://i.imgur.com/g7KgZHf.png" - elif event == 19: + elif action == 19: link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"], user=params["blocked_user"].replace(" ", "_").replace(')', '\)')) user = params["blocked_user"].split(':')[1] embed["title"] = _("Reapplied the block on {blocked_user}").format(blocked_user=user) colornumber = 1 embed["author"]["icon_url"] = "https://i.imgur.com/g7KgZHf.png" - elif event == 18: + elif action == 18: link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"], user=params["blocked_user"].replace(" ", "_").replace(')', '\)')) user = params["blocked_user"].split(':')[1] embed["title"] = _("Removed the block on {blocked_user}").format(blocked_user=user) colornumber = 1 embed["author"]["icon_url"] = "https://i.imgur.com/g7KgZHf.png" - elif event == 25: + elif action == 25: link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)')) embed["title"] = _("Left a comment on {target}'s profile").format(target=params["target"]) - elif event == 29: + elif action == 29: link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)')) embed["title"] = _("Replied to a comment on {target}'s profile").format(target=params["target"]) - elif event == 26: + elif action == 26: link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)')) embed["title"] = _("Edited a comment on {target}'s profile").format(target=params["target"]) - elif event == 28: + elif action == 28: link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)')) if params["field"] == "profile-location": field = _("Location") @@ -185,10 +185,10 @@ def webhook_formatter(action, timestamp, **params): field = _("Unknown") embed["title"] = _("Edited {target}'s profile").format(target=params["target"]) params["desc"] = _("{field} field changed to: {desc}").format(field=field, desc=params["desc"]) - elif event == 27: + elif action == 27: link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)')) embed["title"] = _("Removed a comment on {target}'s profile").format(target=params["target"]) - elif event == 20: + elif action == 20: link = "https://{wiki}.gamepedia.com/"+params["user"].replace(" ", "_").replace(')', '\)') embed["title"] = _("Changed {target}'s user groups").format(target=params["user"]) if params["old_groups"].count(' ') < params["new_groups"].count(' '): @@ -198,75 +198,75 @@ def webhook_formatter(action, timestamp, **params): if len(params["new_groups"]) < 4: params["new_groups"] = _("none") params["desc"] = _("Groups changed from {old_groups} to {new_groups} with reason given: {desc}").format(old_groups=params["old_groups"], new_groups=params["new_groups"], desc=params["desc"]) - elif event == 2: + elif action == 2: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Protected the page {target}").format(target=params["title"]) embed["author"]["icon_url"] ="https://i.imgur.com/Lfk0wuw.png" params["desc"] = params["settings"] + " | " + params["desc"] - elif event == 3: + elif action == 3: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Modified protection settings for {article}").format(article=params["title"]) - params["desc"] = params["desc2"] + " | " + params["desc"] + params["desc"] = params["settings"] + " | " + params["desc"] embed["author"]["icon_url"] ="https://i.imgur.com/Lfk0wuw.png" - elif event == 4: + elif action == 4: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Removed protection for {article}").format(article=params["title"]) embed["author"]["icon_url"] ="https://i.imgur.com/Lfk0wuw.png" - elif event == 9: + elif action == 9: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Removed revision(s) from public view for {article}").format(article=params["title"]) - elif event == 11: + elif action == 11: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Imported {article} with {count} revision(s)").format(article=params["title"], count=params["amount"]) - elif event == 8: + elif action == 8: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Restored {article}").format(article=params["title"]) - elif event == 10: + elif action == 10: link = "https://{wiki}.gamepedia.com/Special:RecentChanges".format(wiki=settings["wiki"]) embed["title"] = _("Removed events") - elif event == 12: + elif action == 12: link = "https://{wiki}.gamepedia.com/Special:RecentChanges".format(wiki=settings["wiki"]) embed["title"] = _("Imported interwiki") - elif event == 21: + elif action == 21: link = "https://{wiki}.gamepedia.com/Special:RecentChanges".format(wiki=settings["wiki"]) embed["title"] = _("Edited abuse filter number {number}").format(number=params["filternr"]) - elif event == 8: + elif action == 8: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Merged revision histories for {article}").format(article=params["title"]) - elif event == 22: + elif action == 22: link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"]) embed["title"] = _("Added interwiki entry") params["desc"] =_("Prefix: {prefix}, website: {website} | {desc}").format(desc=params["desc"], prefix=params["prefix"], website=params["website"]) - elif event == 23: + elif action == 23: link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"]) embed["title"] = _("Edited interwiki entry") params["desc"] =_("Prefix: {prefix}, website: {website} | {desc}").format(desc=params["desc"], prefix=params["prefix"], website=params["website"]) - elif event == 24: + elif action == 24: link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"]) embed["title"] = _("Deleted interwiki entry") params["desc"] =_("Prefix: {prefix} | {desc}").format(desc=params["desc"], prefix=params["prefix"]) - elif event == 30: + elif action == 30: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Changed content model of {article}").format(article=params["title"]) params["desc"] = _("Model changed from {old} to {new}: {reason}").format(old=params["oldmodel"], new=params["newmodel"], reason=params["desc"]) - elif event == 31: + elif action == 31: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Edited the sprite for {article}").format(article=params["title"]) - elif event == 32: + elif action == 32: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Created the sprite sheet for {article}").format(article=params["title"]) - elif event == 33: + elif action == 33: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Edited the slice for {article}").format(article=params["title"]) - elif event == 34: + elif action == 34: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Created a tag \"{tag}\"").format(article=params["additional"]["tag"]) - elif event == 35: + elif action == 35: link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded) embed["title"] = _("Deleted a tag \"{tag}\"").format(article=params["additional"]["tag"]) else: - logging.warning("No entry for {event} with params: {params}".format(event=event, params=params)) - embed["author"]["name"] = params["author"] + logging.warning("No entry for {event} with params: {params}".format(event=action, params=params)) + embed["author"]["name"] = params["user"] embed["author"]["url"] = author_url embed["url"] = link if "desc" not in params: @@ -315,7 +315,7 @@ def first_pass(change): elif logtype=="merge" : webhook_formatter(13, change["timestamp"], user=change["user"], title=change["title"], desc=parsedcomment) elif logtype=="move" and logaction=="move": - webhook_formatter(14, change["timestamp"], user=change["user"], title=change["title"], desc=parsedcomment, supress=True if "suppressredirect" in change["logparams"] else False, target=change["logparams"]['target_title'], targetlink="https://minecraft.gamepedia.com/" + change["logparams"]['target_title'].replace(" ", "_")) #TODO Remove the link making in here + webhook_formatter(14, change["timestamp"], user=change["user"], title=change["title"], desc=parsedcomment, supress=True if "suppressredirect" in change["logparams"] else False, target=change["logparams"]['target_title'], targetlink="https://{wiki}.gamepedia.com/".format(wiki=settings["wiki"]) + change["logparams"]['target_title'].replace(" ", "_")) #TODO Remove the link making in here elif logtype=="move" and logaction=="move_redir": webhook_formatter(15, change["timestamp"], user=change["user"], title=change["title"], desc=parsedcomment, target=change["logparams"]["target_title"]) elif logtype=="protect" and logaction=="move_prot": @@ -412,6 +412,8 @@ class recent_changes(object): self.add_cache(change) if clean: continue + first_pass(change) + time.sleep(0.5) def safe_request(self, url): try: request = requests.get(url, timeout=10, headers=settings["header"]) @@ -444,7 +446,7 @@ class recent_changes(object): self.downtimecredibility+=15 else: if (time.time() - self.last_downtime)>1800 and self.check_connection(): #check if last downtime happened within 30 minutes, if yes, don't send a message - send(_("Minecraft Wiki seems to be down or unreachable."), _("Connection status"), _("https://i.imgur.com/2jWQEt1.png")) + send(_("{wiki} seems to be down or unreachable.").format(wiki=settings["wiki"]), _("Connection status"), _("https://i.imgur.com/2jWQEt1.png")) self.last_downtime = time.time() recent_changes = recent_changes()