service: Refactor "get" command handle, make it robust when compact id has
patch 00e75e93c744727f1f30cb8e409d53b495c500ed
Author: E. Bosch <presidev@AT@gmail.com>
Date: Tue May 16 23:13:51 CEST 2023
* service: Refactor "get" command handle, make it robust when compact id has
not been initialized yet
diff -rN -u old-irgramd/service.py new-irgramd/service.py
--- old-irgramd/service.py 2024-11-22 16:00:55.002769057 +0100
+++ new-irgramd/service.py 2024-11-22 16:00:55.002769057 +0100
@@ -118,16 +118,18 @@
async def handle_command_get(self, peer=None, mid=None, help=None):
if not help:
+ msg = None
peer_id, reply = self.get_peer_id(peer.lower())
if reply: return reply
+ else: reply = ()
id = self.tg.mid.id_to_num_offset(peer_id, mid)
- msg = await self.tg.telegram_client.get_messages(entity=peer_id, ids=id)
- if msg is None:
- reply = ('Message not found',)
- return reply
- await self.tg.handle_telegram_message(event=None, message=msg, history=True)
- reply = ()
+ if id is not None:
+ msg = await self.tg.telegram_client.get_messages(entity=peer_id, ids=id)
+ if msg is not None:
+ await self.tg.handle_telegram_message(event=None, message=msg, history=True)
+ else:
+ reply = ('Message not found',)
return reply
else: # HELP.brief or HELP.desc (first line)