From 757976c8f6c73da5798a2d73dbec5863ff11df50 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 1 May 2022 16:17:51 +0200 Subject: [PATCH] main: Remove Discord webhooks if they are not authenticated --- xmpp_discord_bridge/main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xmpp_discord_bridge/main.py b/xmpp_discord_bridge/main.py index 1faa69e..44487ec 100644 --- a/xmpp_discord_bridge/main.py +++ b/xmpp_discord_bridge/main.py @@ -206,7 +206,11 @@ class BridgeComponent(ComponentXMPP): wh = None for webhook in await dchannel.webhooks(): if webhook.name == "discord-xmpp-bridge": - wh = webhook + if not webhook.is_authenticated(): + _logger.info("Webhook for %s has no token. Deleting and recreating" % muc) + await webhook.delete(reason="Webhook has no token. Will recreate") + else: + wh = webhook break if not wh: wh = await dchannel.create_webhook(name="discord-xmpp-bridge", @@ -526,7 +530,15 @@ def main(): general["port"], general["discord_token"], config) - for xep in [ "0030", "0199", "0045", "0084", "0153", "0054", "0060" ]: + for xep in [ + "0030", + "0199", + "0045", + "0084", + "0153", + "0054", + "0060" + ]: xmpp.register_plugin(f"xep_{xep}") logging.basicConfig(stream=sys.stdout, level=verbosity)