From a495d7d7c8d8926c4388c8195ba9a2a2e9c56a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 12 Mar 2022 01:23:43 +0100 Subject: [PATCH] echo_bot: use f-strings where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- examples/echo_client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/echo_client.py b/examples/echo_client.py index a222e9b..4a5a741 100644 --- a/examples/echo_client.py +++ b/examples/echo_client.py @@ -101,9 +101,9 @@ class EchoBot(ClientXMPP): body = ( 'I\'m the slixmpp-omemo echo bot! ' 'The following commands are available:\n' - '{prefix}verbose Send message or reply with log messages\n' - '{prefix}error Send message or reply only on error\n' - ).format(prefix=self.cmd_prefix) + f'{self.cmd_prefix}verbose Send message or reply with log messages\n' + f'{self.cmd_prefix}error Send message or reply only on error\n' + ) return await self.encrypted_reply(mto, mtype, body) async def cmd_verbose(self, mto: JID, mtype: str) -> None: @@ -136,7 +136,7 @@ class EchoBot(ClientXMPP): if not self['xep_0384'].is_encrypted(msg): if self.debug_level == LEVEL_DEBUG: - await self.plain_reply(mto, mtype, 'Echo unencrypted message:%(body)s' % msg) + await self.plain_reply(mto, mtype, f"Echo unencrypted message:{msg['body']}") return None try: @@ -151,7 +151,7 @@ class EchoBot(ClientXMPP): if self.is_command(decoded): await self.handle_command(mto, mtype, decoded) elif self.debug_level == LEVEL_DEBUG: - await self.encrypted_reply(mto, mtype, 'Echo: %s' % decoded) + await self.encrypted_reply(mto, mtype, f'Echo: {decoded}') return None except (MissingOwnKey,): # The message is missing our own key, it was not encrypted for @@ -185,7 +185,7 @@ class EchoBot(ClientXMPP): # anyway. await self.plain_reply( mto, mtype, - "Error: Your device '%s' is not in my trusted devices." % exn.device, + f"Error: Your device '{exn.device}' is not in my trusted devices.", ) # We resend, setting the `allow_untrusted` parameter to True. await self.message_handler(msg, allow_untrusted=True) @@ -260,8 +260,8 @@ class EchoBot(ClientXMPP): # point can bring up the issue if it happens. self.plain_reply( mto, mtype, - 'Could not find keys for device "%d" of recipient "%s". Skipping.' % - (error.device, error.bare_jid), + f'Could not find keys for device "{error.device}"' + f' of recipient "{error.bare_jid}". Skipping.', ) jid = JID(error.bare_jid) device_list = expect_problems.setdefault(jid, [])