patch 1fb88a2962a05a4a46ccec54dc3ae3b65f73ab78
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Oct 15 22:06:49 CEST 2023
* telegram: Add option "download_media" to control if media files must be downloaded
diff -rN -u old-irgramd/irgramd new-irgramd/irgramd
--- old-irgramd/irgramd 2024-11-22 11:38:18.679730321 +0100
+++ new-irgramd/irgramd 2024-11-22 11:38:18.679730321 +0100
@@ -73,6 +73,7 @@
tornado.options.define('char_out_encoding', default='utf-8', metavar='ENCODING', help='Character output encoding for IRC')
tornado.options.define('config', default='irgramdrc', metavar='CONFIGFILE', help='Config file absolute or relative to `config_dir` (command line options override it)')
tornado.options.define('config_dir', default='~/.config/irgramd', metavar='PATH', help='Configuration directory where telegram session info is saved')
+ tornado.options.define('download_media', default=True, help='Enable download of any media (photos, documents, etc.), if not set only a message of media will be shown')
tornado.options.define('emoji_ascii', default=False, help='Replace emoji with ASCII emoticons')
tornado.options.define('geo_url', type=str, default=None, metavar='TEMPLATE_URL', help='Use custom URL for showing geo latitude/longitude location, eg. OpenStreetMap')
tornado.options.define('hist_timestamp_format', metavar='DATETIME_FORMAT', help='Format string for timestamps in history, see https://www.strfti.me')
diff -rN -u old-irgramd/telegram.py new-irgramd/telegram.py
--- old-irgramd/telegram.py 2024-11-22 11:38:18.679730321 +0100
+++ new-irgramd/telegram.py 2024-11-22 11:38:18.683730315 +0100
@@ -38,6 +38,7 @@
def __init__(self, irc, settings):
self.logger = logging.getLogger()
self.config_dir = settings['config_dir']
+ self.download = settings['download_media']
self.media_dir = settings['media_dir']
self.media_url = settings['media_url']
self.api_id = settings['api_id']
@@ -824,7 +825,9 @@
return '[{}] {}{}'.format(media_type, media_url_or_data, caption)
async def download_telegram_media(self, message):
- local_path = await message.download_media(self.telegram_media_dir)
+ local_path = None
+ if self.download:
+ local_path = await message.download_media(self.telegram_media_dir)
if not local_path: return ''
if message.document: