Skip to content

Commit 90a50b6

Browse files
committed
Revert "Fix splitting of long messages"
This reverts commit 62fb560 fix #22
1 parent 424fe6a commit 90a50b6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

mattermost.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# Mattermost message limit is 4000 chars, need to leave some space for
2121
# backticks when messages are split
22-
MATTERMOST_MESSAGE_LIMIT = 3980
22+
MATTERMOST_MESSAGE_LIMIT = 3994
2323

2424
# Default websocket timeout - this is needed to send a heartbeat
2525
# to keep the connection alive
@@ -453,11 +453,10 @@ def prepare_message_body(self, body, size_limit):
453453
Returns:
454454
[str]
455455
"""
456+
fixed_format = body.startswith('```') # hack to fix the formatting
456457
parts = list(split_string_after(body, size_limit))
457458

458459
if len(parts) == 1:
459-
if not body.startswith('```'):
460-
parts[0] = '```\n' + parts[0]
461460
# If we've got an open fixed block, close it out
462461
if parts[0].count('```') % 2 != 0:
463462
parts[0] += '\n```\n'
@@ -466,7 +465,7 @@ def prepare_message_body(self, body, size_limit):
466465
starts_with_code = part.startswith('```')
467466

468467
# If we're continuing a fixed block from the last part
469-
if not starts_with_code:
468+
if fixed_format and not starts_with_code:
470469
parts[i] = '```\n' + part
471470

472471
# If we've got an open fixed block, close it out

0 commit comments

Comments
 (0)