From 6196d7e8b3f0c81111b8152f8b3ead35f190c2dc Mon Sep 17 00:00:00 2001 From: Tristan Gosselin-Hane Date: Fri, 14 Dec 2018 02:48:16 -0500 Subject: [PATCH] Embed attachment links into minecraft chat. (broken for now) This is broken by design because the bridge's message masquerading deletes the original image and this the link 404s by the time it is posted in chat. I will need to figure out a workaround before merging this. --- webhook-bridge.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webhook-bridge.py b/webhook-bridge.py index c54d719..1fd7e4f 100755 --- a/webhook-bridge.py +++ b/webhook-bridge.py @@ -627,12 +627,20 @@ def main(): message.clean_content.encode('utf-8').decode('ascii', 'replace')).strip() message_to_discord = escape_markdown(message.clean_content) + if len(message.attachments) > 0: + for attach in message.attachments: + message_to_send = "{} {}".format(message_to_send, attach.url) + message_to_discord = "{} {}".format(message_to_discord, attach.url) + total_len = padding + len(message_to_send) if total_len > 256: message_to_send = message_to_send[:(256 - padding)] message_to_discord = message_to_discord[:(256 - padding)] elif len(message_to_send) <= 0: - return + if len(message.attachments) > 0: + pass + else: + return session = database_session.get_session() channels = session.query(DiscordChannel).all()