patch c36c361baf23612e31780ba510278ceef611b7ec
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Nov 26 23:13:52 CET 2023
* telegram: Add support for the change of channel photo action
including download of the new photo
mapped to CTCP action on IRC
hunk ./telegram.py 668
+ elif isinstance(message.action, tgty.MessageActionChatEditPhoto):
+ _, media_type = self.scan_photo_attributes(message.action.photo)
+ photo_url = await self.download_telegram_media(message)
+ action_text = 'has changed chat [{}] {}'.format(media_type, photo_url)
hunk ./telegram.py 749
- ph_size = message.media.photo.sizes[-1]
- if isinstance(ph_size, tgty.PhotoSizeProgressive):
- size = ph_size.sizes[-1]
- else:
- 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:
- media_type = 'photo'
+ size, media_type = self.scan_photo_attributes(message.media.photo)
hunk ./telegram.py 867
+ def scan_photo_attributes(self, photo):
+ size = 0
+ sizes = photo.sizes
+ ph_size = sizes[-1]
+ if isinstance(ph_size, tgty.PhotoSizeProgressive):
+ size = ph_size.sizes[-1]
+ else:
+ for x in sizes:
+ if isinstance(x, tgty.PhotoSize):
+ if x.size > size:
+ size = x.size
+ ph_size = x
+ if hasattr(ph_size, 'w') and hasattr(ph_size, 'h'):
+ media_type = 'photo:{}x{}'.format(ph_size.w, ph_size.h)
+ else:
+ media_type = 'photo'
+
+ return size, media_type
+