From a718ab6f86b8b9f1cdc543a74bc0312ef001e078 Mon Sep 17 00:00:00 2001 From: Alexander PapaTutuWawa Date: Sun, 19 Sep 2021 13:01:14 +0200 Subject: [PATCH] xmpp: Fix Discord embeds --- xmpp_discord_bridge/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xmpp_discord_bridge/main.py b/xmpp_discord_bridge/main.py index d8e1c37..e779ef7 100644 --- a/xmpp_discord_bridge/main.py +++ b/xmpp_discord_bridge/main.py @@ -24,6 +24,8 @@ from xmpp_discord_bridge.avatar import AvatarManager from xmpp_discord_bridge.discord import DiscordClient from xmpp_discord_bridge.helpers import discord_status_to_xmpp_show +# TODO: Move into separate file +# TODO: Add an option that allows a real user to join the MUC to replace a virtual one class BridgeComponent(ComponentXMPP): def __init__(self, jid, secret, server, port, token, config): ComponentXMPP.__init__(self, jid, secret, server, port) @@ -251,7 +253,17 @@ class BridgeComponent(ComponentXMPP): member.mention) if message["oob"]["url"] and message["body"] == message["oob"]["url"]: - embed = Embed(url=message["oob"]["url"], type="rich") + # TODO: Quick and dirty hack. Discord requires a webhook embed to have + # a description + description = message["oob"]["url"].split("/")[-1] + embed = Embed(url=message["oob"]["url"], type="rich", description=description) + embed.set_image(url=message["oob"]["url"]) + + # I mean, this should always be true, but you never know + if content == message["oob"]["url"]: + # NOTE: To prevent the URL being visible in Discord, remove the content. + # Makes it feel more native. + content = None try: await self._webhooks[muc].send(content=content,