Move compact emoji to class

This commit is contained in:
Markus-Rost 2020-12-13 22:01:51 +01:00
parent 88b22457a2
commit 546ccc0ada
5 changed files with 20 additions and 7 deletions

View file

@ -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>"
}
}
}

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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)