xmpp: Fix Discord embeds
This commit is contained in:
parent
8aeb098b0f
commit
a718ab6f86
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user