From 546ccc0ada4ba16d1331072f3dc2b1678a67c7f5 Mon Sep 17 00:00:00 2001 From: Markus-Rost Date: Sun, 13 Dec 2020 22:01:51 +0100 Subject: [PATCH] Move compact emoji to class --- settings.json.example | 19 +++++++++++++++++-- src/config.py | 2 +- src/discord.py | 2 ++ src/formatters/discussions.py | 2 -- src/formatters/rc.py | 2 -- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/settings.json.example b/settings.json.example index 48dc7d0..f18c9ef 100644 --- a/settings.json.example +++ b/settings.json.example @@ -456,12 +456,17 @@ "color": 1, "emoji": "👁️" }, - "discussion/forum/post": { + "discussion": { "icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada", "color": 54998, "emoji": "📝" }, - "discussion/forum/reply": { + "discussion/forum/post": { + "icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada", + "color": 54998, + "emoji": "📝" + }, + "discussion/forum/reply": { "icon": "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada", "color": 54998, "emoji": "📝" @@ -500,6 +505,16 @@ "icon": "", "color": 0, "emoji": "❓" + }, + "webhook/remove": { + "icon": "https://raw.githubusercontent.com/Markus-Rost/discord-wiki-bot/master/dashboard/src/icon.png", + "color": 0, + "emoji": "<:wikibot:588723255972593672>" + }, + "bot/exception": { + "icon": "https://raw.githubusercontent.com/Markus-Rost/discord-wiki-bot/master/dashboard/src/icon.png", + "color": 0, + "emoji": "<:wikibot:588723255972593672>" } } } \ No newline at end of file diff --git a/src/config.py b/src/config.py index 53646b3..cffd432 100644 --- a/src/config.py +++ b/src/config.py @@ -1,7 +1,7 @@ import json, sys, logging try: # load settings - with open("settings.json") as sfile: + with open("settings.json", encoding="utf8") as sfile: settings = json.load(sfile) if "user-agent" in settings["header"]: settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.0") # set the version in the useragent diff --git a/src/discord.py b/src/discord.py index b69705b..ac40c82 100644 --- a/src/discord.py +++ b/src/discord.py @@ -50,6 +50,8 @@ class DiscordMessage: if message_type == "embed": self._setup_embed() elif message_type == "compact": + if settings["event_appearance"].get(event_type, {"emoji": None})["emoji"]: + content = settings["event_appearance"][event_type]["emoji"] + " " + content self.webhook_object["content"] = content self.length = len(content) diff --git a/src/formatters/discussions.py b/src/formatters/discussions.py index 1535b88..de9a488 100644 --- a/src/formatters/discussions.py +++ b/src/formatters/discussions.py @@ -71,8 +71,6 @@ async def feeds_compact_formatter(post_type, post, message_target, wiki, article else: message = _("Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format(event=post_type, author=author, author_url=author_url, support=settings["support"]) event_type = "unknown" - if settings["event_appearance"].get(event_type, {"emoji": None})["emoji"]: - message = settings["event_appearance"][event_type]["emoji"] + " " + message return DiscordMessage("compact", event_type, message_target[1], content=message, wiki=wiki) diff --git a/src/formatters/rc.py b/src/formatters/rc.py index 3989c59..1234179 100644 --- a/src/formatters/rc.py +++ b/src/formatters/rc.py @@ -575,8 +575,6 @@ async def compact_formatter(action, change, parsed_comment, categories, recent_c else: content = _("Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format(event=action, author=author, author_url=author_url, support=settings["support"]) action = "unknown" - if settings["event_appearance"].get(action, {"emoji": None})["emoji"]: - content = settings["event_appearance"][action]["emoji"] + " " + content return DiscordMessage("compact", action, message_target[1], content=content, wiki=WIKI_SCRIPT_PATH)