make webhookURL an array

This commit is contained in:
Markus-Rost 2020-08-02 13:44:57 +02:00
parent 65fe19d9aa
commit c7dfba01ea
6 changed files with 13 additions and 9 deletions

View file

@ -169,7 +169,7 @@ def set_webhook():
print("The webhook URL does not seem right. Reason: {}".format(test_webhook.json()["message"]))
return False
else:
settings["webhookURL"] = option
settings["webhookURL"] = [option]
return True
else:
print("A Discord webhook URL should start with https://discord.com/api/webhooks/, are you sure it's the right URL?")

View file

@ -7,7 +7,9 @@
"user-agent": "RcGcDw/{version}"
},
"limit": 10,
"webhookURL": "https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"webhookURL": [
"https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
],
"limitrefetch": 28,
"wikiname": "Wreck It Woodhouse",
"avatars": {
@ -293,7 +295,9 @@
"wiki_id": 1885853,
"wiki_url": "https://wikibot.fandom.com/",
"cooldown": 60,
"webhookURL": "https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"webhookURL": [
"https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
],
"limit": 5,
"appearance": {
"mode": "embed",

View file

@ -14,7 +14,7 @@ discussion_logger = logging.getLogger("rcgcdw.discussion_formatter")
def embed_formatter(post, post_type):
"""Embed formatter for Fandom discussions."""
embed = DiscordMessage("embed", "discussion", settings["fandom_discussions"]["webhookURL"])
embed = DiscordMessage("embed", "discussion", settings["fandom_discussions"]["webhookURL"][int(post["id"]) % len(settings["fandom_discussions"]["webhookURL"])])
embed.set_author(post["createdBy"]["name"], "{wikiurl}f/u/{creatorId}".format(
wikiurl=settings["fandom_discussions"]["wiki_url"], creatorId=post["creatorId"]), icon_url=post["createdBy"]["avatarUrl"])
discussion_post_type = post["_embedded"]["thread"][0].get("containerType", "FORUM") # Can be FORUM, ARTICLE_COMMENT or WALL on UCP
@ -122,7 +122,7 @@ def compact_formatter(post, post_type):
"[{author}](<{url}f/u/{creatorId}>) created a poll [{title}](<{url}f/p/{threadId}>) in {forumName}").format(
author=post["createdBy"]["name"], url=settings["fandom_discussions"]["wiki_url"],
creatorId=post["creatorId"], title=post["title"], threadId=post["threadId"], forumName=post["forumName"])
send_to_discord(DiscordMessage("compact", "discussion", settings["fandom_discussions"]["webhookURL"], content=message))
send_to_discord(DiscordMessage("compact", "discussion", settings["fandom_discussions"]["webhookURL"][int(post["id"]) % len(settings["fandom_discussions"]["webhookURL"])], content=message))
class DiscussionsFromHellParser:

View file

@ -305,7 +305,7 @@ def create_article_path(article: str) -> str:
def send_simple(msgtype, message, name, avatar):
discord_msg = DiscordMessage("compact", msgtype, settings["webhookURL"], content=message)
discord_msg = DiscordMessage("compact", msgtype, settings["webhookURL"][0], content=message)
discord_msg.set_avatar(avatar)
discord_msg.set_name(name)
messagequeue.resend_msgs()

View file

@ -321,11 +321,11 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
else:
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
return
send_to_discord(DiscordMessage("compact", action, settings["webhookURL"], content=content))
send_to_discord(DiscordMessage("compact", action, settings["webhookURL"][change["rcid"] % len(settings["webhookURL"])], content=content))
def embed_formatter(action, change, parsed_comment, categories, recent_changes):
embed = DiscordMessage("embed", action, settings["webhookURL"])
embed = DiscordMessage("embed", action, settings["webhookURL"][change["rcid"] % len(settings["webhookURL"])])
if parsed_comment is None:
parsed_comment = _("No description provided")
if action != "suppressed":

View file

@ -140,7 +140,7 @@ def day_overview():
changed_bytes = 0
new_articles = 0
active_articles = []
embed = DiscordMessage("embed", "daily_overview", settings["webhookURL"])
embed = DiscordMessage("embed", "daily_overview", settings["webhookURL"][0])
embed["title"] = _("Daily overview")
embed["url"] = create_article_path("Special:Statistics")
embed.set_author(settings["wikiname"], create_article_path(""),