comparison sat_frontends/jp/cmd_message.py @ 3805:33ab258df0de

cli (message/retract): message retractation command: rel 367
author Goffi <goffi@goffi.org>
date Fri, 17 Jun 2022 14:15:23 +0200
parents be6d91572633
children 6090141b1b70
comparison
equal deleted inserted replaced
3804:36b167ddbfca 3805:33ab258df0de
183 except Exception as e: 183 except Exception as e:
184 self.disp(f"can't start encryption session: {e}", error=True) 184 self.disp(f"can't start encryption session: {e}", error=True)
185 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 185 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
186 186
187 await self.sendStdin(jid_) 187 await self.sendStdin(jid_)
188
189
190 class Retract(base.CommandBase):
191
192 def __init__(self, host):
193 super().__init__(host, "retract", help=_("retract a message"))
194
195 def add_parser_options(self):
196 self.parser.add_argument(
197 "message_id",
198 help=_("ID of the message (internal ID)")
199 )
200
201 async def start(self):
202 try:
203 await self.host.bridge.messRetract(
204 self.args.message_id,
205 self.profile
206 )
207 except Exception as e:
208 self.disp(f"can't retract message: {e}", error=True)
209 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
210 else:
211 self.disp(
212 "message retraction has been requested, please note that this is a "
213 "request which can't be enforced (see documentation for details).")
214 self.host.quit(C.EXIT_OK)
188 215
189 216
190 class MAM(base.CommandBase): 217 class MAM(base.CommandBase):
191 218
192 def __init__(self, host): 219 def __init__(self, host):
267 294
268 self.host.quit() 295 self.host.quit()
269 296
270 297
271 class Message(base.CommandBase): 298 class Message(base.CommandBase):
272 subcommands = (Send, MAM) 299 subcommands = (Send, Retract, MAM)
273 300
274 def __init__(self, host): 301 def __init__(self, host):
275 super(Message, self).__init__( 302 super(Message, self).__init__(
276 host, "message", use_profile=False, help=_("messages handling") 303 host, "message", use_profile=False, help=_("messages handling")
277 ) 304 )