mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Resolved TODO with sending a removal reason to the webhook
This commit is contained in:
parent
fab76d7355
commit
56f6ef1887
16
src/wiki.py
16
src/wiki.py
|
@ -13,7 +13,7 @@ import requests
|
|||
|
||||
from src.api.util import default_message
|
||||
from src.misc import prepare_settings, run_hooks
|
||||
from src.discord.queue import messagequeue, QueueEntry
|
||||
from src.discord.queue import messagequeue, QueueEntry, send_to_discord_webhook
|
||||
from src.mw_messages import MWMessages
|
||||
from src.exceptions import *
|
||||
from src.queue_handler import dbmanager
|
||||
|
@ -496,8 +496,20 @@ class Wiki:
|
|||
|
||||
async def remove_webhook_from_db(self, webhook_url: str, reason: str, send_reason=False):
|
||||
logger.info(f"Removing a webhook with ID of {webhook_url.split('/')[0]} from the database due to {reason}.")
|
||||
# TODO Write a reason for removal to a webhook if send_reason
|
||||
dbmanager.add(("DELETE FROM rcgcdb WHERE webhook = $1", (webhook_url,)))
|
||||
if not send_reason:
|
||||
return
|
||||
lang = "en"
|
||||
for combination, webhooks in self.rc_targets.items():
|
||||
if webhook_url in webhooks:
|
||||
lang = combination.lang
|
||||
lang = langs[lang]["wiki"]
|
||||
try: # This is best effort scenario, but I don't plan to add re-tries to this
|
||||
dc_msg = DiscordMessage("compact", "custom/webhook_removal",
|
||||
[webhook_url], content=lang.gettext("This recent changes webhook has been removed for `{reason}`!".format(reason=reason)))
|
||||
await send_to_discord_webhook(dc_msg, webhook_url, "POST")
|
||||
except:
|
||||
logger.exception("Webhook removal send_reason failure.")
|
||||
|
||||
async def remove_wiki_from_db(self, reason: str):
|
||||
raise NotImplementedError # TODO
|
||||
|
|
Loading…
Reference in a new issue