patch d4f07b39c63d6cfefbf3f3c7bd91fac6969ce39d
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Apr 9 01:07:35 CEST 2023
* telegram: Refactorize relay message functions, this will be necessary for deleted message support
hunk ./telegram.py 339
- if event.message.is_private:
+ chan = await self.relay_telegram_message(event, user, message)
+
+ self.add_to_cache(event.message.id, mid, message, user, chan)
+
+ self.refwd_me = False
+
+ async def relay_telegram_message(self, event, user, message, channel=None):
+ private = (event and event.message.is_private) or (not event and not channel)
+ if private:
hunk ./telegram.py 351
- chan = await self.relay_telegram_channel_message(event, user, message)
-
- self.add_to_cache(event.message.id, mid, message, user, chan)
-
- self.refwd_me = False
+ chan = await self.relay_telegram_channel_message(event, user, message, channel)
+ return chan
hunk ./telegram.py 359
- async def relay_telegram_channel_message(self, event, user, message):
+ async def relay_telegram_channel_message(self, event, user, message, channel=None):
hunk ./telegram.py 362
- entity = await event.message.get_chat()
- channel = await self.get_irc_channel_from_telegram_id(event.message.chat_id, entity)
- await self.irc.send_msg(user, channel, message)
- return channel
+ if event:
+ entity = await event.message.get_chat()
+ chan = await self.get_irc_channel_from_telegram_id(event.message.chat_id, entity)
+ else:
+ chan = channel
+ await self.irc.send_msg(user, chan, message)
+ return chan