telegram: Rename option 'reply_length' as 'quote_length' and use it for quotes in reactions as well (not only for replies)
patch 9fdc513df921e5f956b93feb4f061add2c55c548
Author: E. Bosch <presidev@AT@gmail.com>
Date: Wed Apr 26 20:45:17 CEST 2023
* telegram: Rename option 'reply_length' as 'quote_length' and use it for quotes in reactions as well (not only for replies)
hunk ./irgramd 83
- tornado.options.define('reply_length', default=50, metavar='LENGTH', help='Max length of the text refered in replies, if longer is truncated')
+ tornado.options.define('quote_length', default=50, metavar='LENGTH', help='Max length of the text quoted in replies and reactions, if longer is truncated')
hunk ./telegram.py 25
-from utils import sanitize_filename, is_url_equiv, extract_url, get_human_size, get_human_duration, get_highlighted
+from utils import sanitize_filename, is_url_equiv, extract_url, get_human_size, get_human_duration, get_highlighted, fix_braces
hunk ./telegram.py 50
- self.reply_len = settings['reply_length']
+ self.quote_len = settings['quote_length']
hunk ./telegram.py 390
- if len(message_rendered) > 50:
- text_old = '{}...'.format(message_rendered[:50])
+ if len(message_rendered) > self.quote_len:
+ text_old = '{}...'.format(message_rendered[:self.quote_len])
+ text_old = fix_braces(text_old)
hunk ./telegram.py 532
- elif len(message) > self.reply_len:
- message = message[:self.reply_len]
+ elif len(message) > self.quote_len:
+ message = message[:self.quote_len]
hunk ./utils.py 166
+
+def fix_braces(text):
+ # Remove braces not closed, if the text was truncated
+ if text.endswith(' {...'):
+ subtext = text[:-5]
+ if not '{}' in subtext:
+ return '{}...'.format(subtext)
+ return text