mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
make webhookURL an array
This commit is contained in:
parent
65fe19d9aa
commit
c7dfba01ea
|
@ -169,7 +169,7 @@ def set_webhook():
|
||||||
print("The webhook URL does not seem right. Reason: {}".format(test_webhook.json()["message"]))
|
print("The webhook URL does not seem right. Reason: {}".format(test_webhook.json()["message"]))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
settings["webhookURL"] = option
|
settings["webhookURL"] = [option]
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print("A Discord webhook URL should start with https://discord.com/api/webhooks/, are you sure it's the right URL?")
|
print("A Discord webhook URL should start with https://discord.com/api/webhooks/, are you sure it's the right URL?")
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
"user-agent": "RcGcDw/{version}"
|
"user-agent": "RcGcDw/{version}"
|
||||||
},
|
},
|
||||||
"limit": 10,
|
"limit": 10,
|
||||||
"webhookURL": "https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
"webhookURL": [
|
||||||
|
"https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
],
|
||||||
"limitrefetch": 28,
|
"limitrefetch": 28,
|
||||||
"wikiname": "Wreck It Woodhouse",
|
"wikiname": "Wreck It Woodhouse",
|
||||||
"avatars": {
|
"avatars": {
|
||||||
|
@ -293,7 +295,9 @@
|
||||||
"wiki_id": 1885853,
|
"wiki_id": 1885853,
|
||||||
"wiki_url": "https://wikibot.fandom.com/",
|
"wiki_url": "https://wikibot.fandom.com/",
|
||||||
"cooldown": 60,
|
"cooldown": 60,
|
||||||
"webhookURL": "https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
"webhookURL": [
|
||||||
|
"https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
],
|
||||||
"limit": 5,
|
"limit": 5,
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"mode": "embed",
|
"mode": "embed",
|
||||||
|
|
|
@ -14,7 +14,7 @@ discussion_logger = logging.getLogger("rcgcdw.discussion_formatter")
|
||||||
|
|
||||||
def embed_formatter(post, post_type):
|
def embed_formatter(post, post_type):
|
||||||
"""Embed formatter for Fandom discussions."""
|
"""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(
|
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"])
|
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
|
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}](<{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"],
|
author=post["createdBy"]["name"], url=settings["fandom_discussions"]["wiki_url"],
|
||||||
creatorId=post["creatorId"], title=post["title"], threadId=post["threadId"], forumName=post["forumName"])
|
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:
|
class DiscussionsFromHellParser:
|
||||||
|
|
|
@ -305,7 +305,7 @@ def create_article_path(article: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def send_simple(msgtype, message, name, avatar):
|
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_avatar(avatar)
|
||||||
discord_msg.set_name(name)
|
discord_msg.set_name(name)
|
||||||
messagequeue.resend_msgs()
|
messagequeue.resend_msgs()
|
||||||
|
|
|
@ -321,11 +321,11 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
|
||||||
else:
|
else:
|
||||||
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
||||||
return
|
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):
|
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:
|
if parsed_comment is None:
|
||||||
parsed_comment = _("No description provided")
|
parsed_comment = _("No description provided")
|
||||||
if action != "suppressed":
|
if action != "suppressed":
|
||||||
|
|
|
@ -140,7 +140,7 @@ def day_overview():
|
||||||
changed_bytes = 0
|
changed_bytes = 0
|
||||||
new_articles = 0
|
new_articles = 0
|
||||||
active_articles = []
|
active_articles = []
|
||||||
embed = DiscordMessage("embed", "daily_overview", settings["webhookURL"])
|
embed = DiscordMessage("embed", "daily_overview", settings["webhookURL"][0])
|
||||||
embed["title"] = _("Daily overview")
|
embed["title"] = _("Daily overview")
|
||||||
embed["url"] = create_article_path("Special:Statistics")
|
embed["url"] = create_article_path("Special:Statistics")
|
||||||
embed.set_author(settings["wikiname"], create_article_path(""),
|
embed.set_author(settings["wikiname"], create_article_path(""),
|
||||||
|
|
Loading…
Reference in a new issue