Skip to content

Commit

Permalink
Revert "Fix splitting of long messages"
Browse files Browse the repository at this point in the history
This reverts commit 62fb560

fix #22
  • Loading branch information
Vaelor committed Aug 8, 2017
1 parent 424fe6a commit 90a50b6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Mattermost message limit is 4000 chars, need to leave some space for
# backticks when messages are split
MATTERMOST_MESSAGE_LIMIT = 3980
MATTERMOST_MESSAGE_LIMIT = 3994

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

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

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

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

0 comments on commit 90a50b6

Please sign in to comment.