telegram: Add 'reply_length' option to limit the length of the text refered in replies
patch aedc28b24f83d3fb3266bb7effe4cb7dcb3f7414
Author: E. Bosch <presidev@AT@gmail.com>
Date: Wed Mar 29 21:07:06 CEST 2023
* telegram: Add 'reply_length' option to limit the length of the text refered in replies
diff -rN -u old-irgramd/irgramd new-irgramd/irgramd
--- old-irgramd/irgramd 2024-11-22 21:49:55.025528400 +0100
+++ new-irgramd/irgramd 2024-11-22 21:49:55.029528394 +0100
@@ -80,6 +80,7 @@
tornado.options.define('pam', default=False, help='Use PAM for IRC authentication, if not set you should set `irc_password`')
tornado.options.define('pam_group', default=None, metavar='GROUP', help='Unix group allowed if `pam` enabled, if empty any user is allowed')
tornado.options.define('phone', default=None, metavar='PHONE_NUMBER', help='Phone number associated with the Telegram account to receive the authorization codes if necessary')
+ 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('service_user', default='TelegramServ', metavar='SERVICE_NICK', help='Nick of the service/control user, must be a nick not used by a real Telegram user')
tornado.options.define('test', default=False, help='Connect to Telegram test environment')
tornado.options.define('test_datacenter', default=2, metavar='DATACENTER_NUMBER', help='Datacenter to connect to Telegram test environment')
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-22 21:49:55.029528394 +0100
+++ new-irgramd/telegram.py 2024-11-22 21:49:55.029528394 +0100
@@ -44,6 +44,7 @@
self.test_ip = settings['test_host'] if settings['test_host'] else TEST_IPS[self.test_dc]
self.test_port = settings['test_port']
self.ask_code = settings['ask_code']
+ self.reply_len = settings['reply_length']
self.media_cn = 0
self.irc = irc
self.authorized = False
@@ -379,8 +380,8 @@
message = replied.message
if not message:
message = '[{}]'.format(self.mid.num_to_id(replied.id - self.mid.mesg_base))
- elif len(message) > 30:
- message = message[:30]
+ elif len(message) > self.reply_len:
+ message = message[:self.reply_len]
trunc = '...'
replied_user = self.get_irc_user_from_telegram(replied.sender_id)
if replied_user is None: