interrealm: Fix the msg formatting with special prefixes.

Tweaked by tabbott to cover all code blocks, not just quote blocks.

See https://chat.zulip.org/#narrow/stream/127-integrations/topic/cross.20realm.20bridge/near/695907
This commit is contained in:
rht 2019-02-08 00:57:22 +00:00 committed by Tim Abbott
parent be4f9a0c32
commit 6368b63e6c

View file

@ -34,6 +34,10 @@ def create_pipe_event(to_client: zulip.Client, from_bot: Dict[str, Any],
# comes from # comes from
msg["content"] = msg["content"].replace("/user_uploads/", msg["content"] = msg["content"].replace("/user_uploads/",
from_bot["site"] + "/user_uploads/") from_bot["site"] + "/user_uploads/")
if msg["content"].startswith(("```", "- ", "* ", "> ", "1. ")):
# If a message starts with special prefixes, make sure to prepend a newline for
# formatting purpose
msg["content"] = "\n" + msg["content"]
msg_data = { msg_data = {
"sender": to_client.email, "sender": to_client.email,
"type": "stream", "type": "stream",