Made the tags section show tag display name instead of internal name

This commit is contained in:
Frisk 2018-06-25 12:45:48 +02:00
parent d8169f1486
commit e69e342df1
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C
2 changed files with 42 additions and 24 deletions

View file

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2018-06-25 11:08+0200\n"
"POT-Creation-Date: 2018-06-25 12:45+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -177,7 +177,7 @@ msgstr ""
msgid "none"
msgstr ""
#: rcgcdw.py:224 rcgcdw.py:337
#: rcgcdw.py:224 rcgcdw.py:349
msgid "No description provided"
msgstr ""
@ -269,87 +269,87 @@ msgstr ""
msgid "Created a tag \"{tag}\""
msgstr ""
#: rcgcdw.py:288
#: rcgcdw.py:289
msgid "Deleted a tag \"{tag}\""
msgstr ""
#: rcgcdw.py:291
#: rcgcdw.py:293
msgid "Activated a tag \"{tag}\""
msgstr ""
#: rcgcdw.py:294
#: rcgcdw.py:296
msgid "Deactivated a tag \"{tag}\""
msgstr ""
#: rcgcdw.py:431
#: rcgcdw.py:443
msgid "Unable to process the event"
msgstr ""
#: rcgcdw.py:431
#: rcgcdw.py:443
msgid "error"
msgstr ""
#: rcgcdw.py:511
#: rcgcdw.py:523
msgid "Daily overview"
msgstr ""
#: rcgcdw.py:527
#: rcgcdw.py:539
msgid " ({} actions)"
msgstr ""
#: rcgcdw.py:528
#: rcgcdw.py:540
msgid " UTC ({} actions)"
msgstr ""
#: rcgcdw.py:530 rcgcdw.py:531
#: rcgcdw.py:542 rcgcdw.py:543
msgid "But nobody came"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Admin actions"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Bytes changed"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Day score"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Edits made"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Most active hours"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Most active users"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "New articles"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "New files"
msgstr ""
#: rcgcdw.py:536
#: rcgcdw.py:547
msgid "Unique contributors"
msgstr ""
#: rcgcdw.py:649
#: rcgcdw.py:661
msgid "Connection status"
msgstr ""
#: rcgcdw.py:649
#: rcgcdw.py:661
msgid "{wiki} seems to be down or unreachable."
msgstr ""
#: rcgcdw.py:659
#: rcgcdw.py:680
msgid "{wiki} is back up!"
msgstr ""

View file

@ -283,9 +283,11 @@ def webhook_formatter(action, STATIC, **params):
elif action == 34:
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded)
embed["title"] = _("Created a tag \"{tag}\"").format(tag=params["additional"]["tag"])
recent_changes.update_tags()
elif action == 35:
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded)
embed["title"] = _("Deleted a tag \"{tag}\"").format(tag=params["additional"]["tag"])
recent_changes.update_tags()
elif action == 36:
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"], article=article_encoded)
embed["title"] = _("Activated a tag \"{tag}\"").format(tag=params["additional"]["tag"])
@ -304,9 +306,15 @@ def webhook_formatter(action, STATIC, **params):
embed["color"] = random.randrange(1, 16777215) if colornumber is None else math.floor(colornumber)
embed["timestamp"] = STATIC["timestamp"]
if STATIC["tags"]:
tag_displayname = []
if "fields" not in embed:
embed["fields"] = []
embed["fields"].append({"name": "Tags", "value": ", ".join(STATIC["tags"])})
for tag in STATIC["tags"]:
if tag in recent_changes.tags:
tag_displayname.append(recent_changes.tags[tag])
else:
tag_displayname.append(tag)
embed["fields"].append({"name": "Tags", "value": ", ".join(tag_displayname)})
data["embeds"].append(dict(embed))
data['avatar_url'] = settings["avatars"]["embed"]
formatted_embed = json.dumps(data, indent=4)
@ -556,6 +564,7 @@ class recent_changes_class(object):
downtimecredibility = 0
last_downtime = 0
clock = 0
tags = {}
if settings["limitrefetch"] != -1:
with open("lastchange.txt", "r") as record:
file_content = record.read().strip()
@ -653,8 +662,17 @@ class recent_changes_class(object):
self.last_downtime = time.time()
def clear_cache(self):
self.map_ips = {}
def update_tags(self):
tags_read = safe_read(self.safe_request("https://{wiki}.gamepedia.com/api.php?action=query&format=json&list=tags&tgprop=name%7Cdisplayname".format(wiki=settings["wiki"])), "query", "tags")
if tags_read:
for tag in tags_read:
self.tags[tag["name"]] = (BeautifulSoup(tag["displayname"], "lxml")).get_text()
else:
logging.warning("Could not retrive tags. Internal names will be used!")
recent_changes = recent_changes_class()
recent_changes.update_tags()
time.sleep(1.0)
recent_changes.fetch(amount=settings["limitrefetch" ] if settings["limitrefetch"] != -1 else settings["limit"])
schedule.every(settings["cooldown"]).seconds.do(recent_changes.fetch)