From b3ee8bcece1c82d930b9fd8c981d6a0bfbe4e42d Mon Sep 17 00:00:00 2001 From: blank X Date: Fri, 4 Sep 2020 16:13:20 +0700 Subject: [PATCH] Make capping sexier --- redditbot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/redditbot.py b/redditbot.py index f5c68b7..b08bb64 100644 --- a/redditbot.py +++ b/redditbot.py @@ -252,9 +252,13 @@ async def main(): await _start_broadcast(captions, files, chats) else: if getattr(random_post, 'selftext', None): - text += '\n' - caplength = 4095 - len(client.parse_mode.parse(text)[0]) - text += html.escape(random_post.selftext[:caplength]) + caplength = 4094 - len(client.parse_mode.parse(text)[0]) + text += '\n\n' + captext = random_post.selftext[:caplength] + if len(captext) >= caplength: + captext = captext[:-1] + captext += '…' + text += html.escape(captext) await _start_broadcast([text], None, chats) def register(pattern):