echo_bot: change messages style

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2021-07-12 19:26:24 +02:00
parent d9b77dbf86
commit cea2345f29
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -82,21 +82,21 @@ class EchoBot(ClientXMPP):
return None
if not self['xep_0384'].is_encrypted(msg):
await self.plain_reply(msg, 'This message was not encrypted.\n%(body)s' % msg)
await self.plain_reply(msg, 'Echo unencrypted message:%(body)s' % msg)
return None
try:
mfrom = msg['from']
encrypted = msg['omemo_encrypted']
body = self['xep_0384'].decrypt_message(encrypted, mfrom, allow_untrusted)
await self.encrypted_reply(msg, 'Thanks for sending\n%s' % body.decode("utf8"))
await self.encrypted_reply(msg, 'Echo: %s' % body.decode("utf8"))
return None
except (MissingOwnKey,):
# The message is missing our own key, it was not encrypted for
# us, and we can't decrypt it.
await self.plain_reply(
msg,
'I can\'t decrypt this message as it is not encrypted for me.',
'Error: Message not encrypted for me.',
)
return None
except (NoAvailableSession,) as exn:
@ -108,7 +108,7 @@ class EchoBot(ClientXMPP):
# where we talk about self-healing messages?
await self.encrypted_reply(
msg,
'I can\'t decrypt this message as it uses an encrypted '
'Error: Message uses an encrypted '
'session I don\'t know about.',
)
return None
@ -123,7 +123,7 @@ class EchoBot(ClientXMPP):
# anyway.
await self.plain_reply(
msg,
"Your device '%s' is not in my trusted devices." % exn.device,
"Error: Your device '%s' is not in my trusted devices." % exn.device,
)
# We resend, setting the `allow_untrusted` parameter to True.
await self.message(msg, allow_untrusted=True)
@ -132,10 +132,10 @@ class EchoBot(ClientXMPP):
# Slixmpp tried its best, but there were errors it couldn't
# resolve. At this point you should have seen other exceptions
# and given a chance to resolve them already.
await self.plain_reply(msg, 'I was not able to decrypt the message.')
await self.plain_reply(mto, mtype, 'Error: I was not able to decrypt the message.')
return None
except (Exception,) as exn:
await self.plain_reply(msg, 'An error occured while attempting decryption.\n%r' % exn)
await self.plain_reply(mto, mtype, 'Error: Exception occured while attempting decryption.\n%r' % exn)
raise
return None