service: Add "mark_read" command to mark chats as read and reset mentions
patch 3ddecf1fe8d1534ab6af10d2b3602245541d4234
Author: E. Bosch <presidev@AT@gmail.com>
Date: Mon May 8 01:04:52 CEST 2023
* service: Add "mark_read" command to mark chats as read and reset mentions
hunk ./service.py 20
+ 'mark_read': (self.handle_command_mark_read, 1, 1),
hunk ./service.py 152
- def get_peer_id(tgt):
- if tgt in self.irc.users or tgt in self.irc.irc_channels:
- peer_id = self.tg.get_tid(tgt)
- reply = None
- else:
- peer_id = None
- reply = ('Unknown user or channel',)
- return peer_id, reply
-
hunk ./service.py 176
- peer_id, reply = get_peer_id(tgt)
+ peer_id, reply = self.get_peer_id(tgt)
hunk ./service.py 217
+ async def handle_command_mark_read(self, peer=None, help=None):
+ if not help:
+ peer_id, reply = self.get_peer_id(peer.lower())
+ if reply: return reply
+
+ await self.tg.telegram_client.send_read_acknowledge(peer_id, clear_mentions=True)
+ reply = ('',)
+ else: # HELP.brief or HELP.desc (first line)
+ reply = (' mark_read Mark messages as read',)
+ if help == HELP.desc: # rest of HELP.desc
+ reply += \
+ (
+ ' mark_read <peer>',
+ 'Mark all messages on <peer> (channel or user) as read, this also will',
+ 'reset the number of mentions to you on <peer>.'
+ )
+ return reply
+
+ def get_peer_id(self, tgt):
+ if tgt in self.irc.users or tgt in self.irc.irc_channels:
+ peer_id = self.tg.get_tid(tgt)
+ reply = None
+ else:
+ peer_id = None
+ reply = ('Unknown user or channel',)
+ return peer_id, reply
+