Better handle the various chat actions
patch 81a49436803aba222ef9afd79fda42cf3e4ce1c2
Author: Peter Bui <pbui@bx612.space>
Date: Thu Jul 18 22:39:17 CEST 2019
* Better handle the various chat actions
Remember that Chats != Channels and that different events will require
different attributes to determine the nick and channel.
hunk ./irtelegramd.py 285
- user = await self.telegram_client.get_input_entity(tid)
+ try:
+ user = await self.telegram_client.get_input_entity(tid)
+ except ValueError:
+ user = await self.telegram_client.get_entity(tid)
hunk ./irtelegramd.py 357
- irc_channel = self.tid_to_iid[event.action_message.to_id.channel_id]
- irc_nick = await self.get_irc_nick_from_telegram_id(event.action_message.from_id)
+ try:
+ irc_channel = self.tid_to_iid[event.action_message.to_id.channel_id]
+ except AttributeError:
+ irc_channel = self.tid_to_iid[event.action_message.to_id.chat_id]
+
+ try: # Join Chats
+ irc_nick = await self.get_irc_nick_from_telegram_id(event.action_message.action.users[0])
+ except (IndexError, AttributeError):
+ try: # Kick
+ irc_nick = await self.get_irc_nick_from_telegram_id(event.action_message.action.user_id)
+ except (IndexError, AttributeError): # Join Channels
+ irc_nick = await self.get_irc_nick_from_telegram_id(event.action_message.from_id)