telegram: Fix recognition of Telegram user, group, channel types
patch 7f549d8b7544443878875c310fea6f1fb6385364
Author: E. Bosch <presidev@AT@gmail.com>
Date: Wed Apr 12 00:43:22 CEST 2023
* telegram: Fix recognition of Telegram user, group, channel types
hunk ./service.py 79
- ' {:<11} {:<9} {:<9} {:4} {:<3} {:<4} {:<6} {}'.format(
+ ' {:<11} {:<9} {:<9} {:5} {:<3} {:<4} {:<6} {}'.format(
hunk ./service.py 86
- ty = 'User' if dialog.is_user else 'Chat' if dialog.is_group else 'Chan'
+ ty = self.tg.get_entity_type(dialog.entity, format='short')
hunk ./service.py 97
- reply += (' {:<11d} {:<9d} {:<9d} {:4} {:<3} {:<4} {:<6} {}'.format(
+ reply += (' {:<11d} {:<9d} {:<9d} {:5} {:<3} {:<4} {:<6} {}'.format(
hunk ./telegram.py 266
- entity_type = self.get_entity_type(entity)
+ entity_type = self.get_entity_type(entity, format='long')
hunk ./telegram.py 294
- def get_entity_type(self, entity):
- return type(entity).__name__
+ def get_entity_type(self, entity, format):
+ if isinstance(entity, tgty.User):
+ short = long = 'User'
+ elif isinstance(entity, tgty.Chat):
+ short = 'Chat'
+ long = 'Chat/Basic Group'
+ elif isinstance(entity, tgty.Channel):
+ if entity.broadcast:
+ short = 'Broad'
+ long = 'Broadcast Channel'
+ elif entity.megagroup:
+ short = 'Mega'
+ long = 'Super/Megagroup Channel'
+ elif entity.gigagroup:
+ short = 'Giga'
+ long = 'Broadcast Gigagroup Channel'
+
+ return short if format == 'short' else long