patch 24a50b886f4cef2e1da003b74921982f5da0941c
Author: E. Bosch <presidev@AT@gmail.com>
Date: Mon Oct 16 00:24:53 CEST 2023
* telegram: Add option "download_notice" to show the start of a big download
hunk ./irgramd 77
+ tornado.options.define('download_notice', default=10, metavar='SIZE (MiB)', help='Enable a notice when a download starts if its size is greater than SIZE, this is useful when a download takes some time to be completed')
hunk ./telegram.py 42
+ self.notice_size = settings['download_notice'] * 1048576
hunk ./telegram.py 555
- text = await self.render_text(msg, mid, upd_to_webpend)
+ text = await self.render_text(msg, mid, upd_to_webpend, user)
hunk ./telegram.py 563
- async def render_text(self, message, mid, upd_to_webpend, history=False):
+ async def render_text(self, message, mid, upd_to_webpend, user=None):
hunk ./telegram.py 567
- text = await self.handle_telegram_media(message)
+ text = await self.handle_telegram_media(message, user, mid)
hunk ./telegram.py 686
- async def handle_telegram_media(self, message):
+ async def handle_telegram_media(self, message, user, mid):
hunk ./telegram.py 690
+ size = 0
hunk ./telegram.py 707
- size = message.media.photo.sizes[-1]
- if hasattr(size, 'w') and hasattr(size, 'h'):
- media_type = 'photo:{}x{}'.format(size.w, size.h)
+ ph_size = message.media.photo.sizes[-1]
+ if isinstance(ph_size, tgty.PhotoSizeProgressive):
+ size = ph_size.sizes[-1]
hunk ./telegram.py 711
+ size = ph_size.size
+ if hasattr(ph_size, 'w') and hasattr(ph_size, 'h'):
+ media_type = 'photo:{}x{}'.format(ph_size.w, ph_size.h)
+ else:
hunk ./telegram.py 719
- size = get_human_size(message.media.document.size)
+ size = message.media.document.size
+ h_size = get_human_size(size)
hunk ./telegram.py 723
- media_type = 'video:{},{}'.format(size, dur)
+ media_type = 'video:{},{}'.format(h_size, dur)
hunk ./telegram.py 728
- size = get_human_size(message.media.document.size)
- media_type = 'file:{}'.format(size)
+ size = message.media.document.size
+ h_size = get_human_size(size)
+ media_type = 'file:{}'.format(h_size)
hunk ./telegram.py 784
+ if self.download and size > self.notice_size:
+ await self.relay_telegram_message(message, user, '[{}] [{}] [Downloading]'.format(mid, media_type))
+