exclam: Add delete (!del) command to delete messages
patch ee2b02319b5759d67df9fcc08fdafbd57a8fcc80
Author: E. Bosch <presidev@AT@gmail.com>
Date: Mon Jul 17 02:37:21 CEST 2023
* exclam: Add delete (!del) command to delete messages
hunk ./exclam.py 19
+ '!del': (self.handle_command_del, 1, 1, -1),
hunk ./exclam.py 37
- chk_msg = await self.tg.telegram_client.get_messages(entity=self.tmp_telegram_id, ids=id)
+ if id is None:
+ chk_msg = None
+ else:
+ chk_msg = await self.tg.telegram_client.get_messages(entity=self.tmp_telegram_id, ids=id)
hunk ./exclam.py 85
+ )
+ return reply
+
+ async def handle_command_del(self, cid=None, help=None):
+ if not help:
+ id, del_msg = await self.check_msg(cid)
+ if del_msg is not None:
+ deleted = await self.tg.telegram_client.delete_messages(self.tmp_telegram_id, del_msg)
+ if deleted[0].pts_count == 0:
+ reply = ('Not possible to delete',)
+ else:
+ self.tmp_tg_msg = None
+ reply = None
+ else:
+ reply = ('Unknown message to delete',)
+ else: # HELP.brief or HELP.desc (first line)
+ reply = (' !del Delete a message',)
+ if help == HELP.desc: # rest of HELP.desc
+ reply += \
+ (
+ ' !del <compact_id>',
+ 'Delete a message with <compact_id> on current channel/chat'