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

xmpp: Fix Discord embeds

+13 -1
+13 -1
xmpp_discord_bridge/main.py
··· 24 24 from xmpp_discord_bridge.discord import DiscordClient 25 25 from xmpp_discord_bridge.helpers import discord_status_to_xmpp_show 26 26 27 + # TODO: Move into separate file 28 + # TODO: Add an option that allows a real user to join the MUC to replace a virtual one 27 29 class BridgeComponent(ComponentXMPP): 28 30 def __init__(self, jid, secret, server, port, token, config): 29 31 ComponentXMPP.__init__(self, jid, secret, server, port) ··· 251 253 member.mention) 252 254 253 255 if message["oob"]["url"] and message["body"] == message["oob"]["url"]: 254 - embed = Embed(url=message["oob"]["url"], type="rich") 256 + # TODO: Quick and dirty hack. Discord requires a webhook embed to have 257 + # a description 258 + description = message["oob"]["url"].split("/")[-1] 259 + embed = Embed(url=message["oob"]["url"], type="rich", description=description) 260 + embed.set_image(url=message["oob"]["url"]) 261 + 262 + # I mean, this should always be true, but you never know 263 + if content == message["oob"]["url"]: 264 + # NOTE: To prevent the URL being visible in Discord, remove the content. 265 + # Makes it feel more native. 266 + content = None 255 267 256 268 try: 257 269 await self._webhooks[muc].send(content=content,