fork of https://f-hub.org/XMPP/xmpp-discord-bridge

main: Remove Discord webhooks if they are not authenticated

+14 -2
+14 -2
xmpp_discord_bridge/main.py
··· 206 206 wh = None 207 207 for webhook in await dchannel.webhooks(): 208 208 if webhook.name == "discord-xmpp-bridge": 209 - wh = webhook 209 + if not webhook.is_authenticated(): 210 + _logger.info("Webhook for %s has no token. Deleting and recreating" % muc) 211 + await webhook.delete(reason="Webhook has no token. Will recreate") 212 + else: 213 + wh = webhook 210 214 break 211 215 if not wh: 212 216 wh = await dchannel.create_webhook(name="discord-xmpp-bridge", ··· 526 530 general["port"], 527 531 general["discord_token"], 528 532 config) 529 - for xep in [ "0030", "0199", "0045", "0084", "0153", "0054", "0060" ]: 533 + for xep in [ 534 + "0030", 535 + "0199", 536 + "0045", 537 + "0084", 538 + "0153", 539 + "0054", 540 + "0060" 541 + ]: 530 542 xmpp.register_plugin(f"xep_{xep}") 531 543 532 544 logging.basicConfig(stream=sys.stdout, level=verbosity)