patch 1a0add76192510876c18329da2e85acd0a16d368
Author: Peter Bui <pbui@bx612.space>
Date: Thu Jul 18 19:06:07 CEST 2019
* abstract resolving telegram_id to irc_nick
The get_irc_nick_from_telegram_id will check if the telegram_id is in
the dictionary. If it is not, it will look it up and add the
appropriate entries.
hunk ./irtelegramd.py 283
+ async def get_irc_nick_from_telegram_id(self, tid):
+ if tid not in self.tid_to_iid:
+ user = await self.telegram_client.get_input_entity(tid)
+ nick = self.get_telegram_nick(user)
+ self.tid_to_iid[tid] = nick
+ self.iid_to_tid[nick] = tid
+
+ return self.tid_to_iid[tid]
+
hunk ./irtelegramd.py 295
- if event.from_id not in self.tid_to_iid:
- user = await self.telegram_client.get_input_entity(event.from_id)
- nick = self.get_telegram_nick(user)
- self.tid_to_iid[user.id] = nick
- self.iid_to_tid[nick] = user.id
-
hunk ./irtelegramd.py 303
- nick = self.tid_to_iid[event.from_id]
+ nick = await self.get_irc_nick_from_telegram_id(event.from_id)
hunk ./irtelegramd.py 325
- nick = self.tid_to_iid[event.from_id]
+ nick = await self.get_irc_nick_from_telegram_id(event.from_id)
hunk ./irtelegramd.py 355
- irc_nick = self.tid_to_iid[event.action_message.from_id]
+ irc_nick = await self.get_irc_nick_from_telegram_id(event.action_message.from_id)