From 46ca444696b0b5374d544c49fea31ce4cff9017d Mon Sep 17 00:00:00 2001 From: kmq Date: Thu, 3 Oct 2024 20:34:31 +0200 Subject: [PATCH] fix: allow sending strings as encrypted replies in echo_client example the `encrypted_reply` function in the echo client example accepts a Message or a string for the reply parameter. But supplying a string caused an error because the variable name `reply` was being reused. This commit introduces a new variable to temporarily hold the reply body, so it can get sent. --- examples/echo_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/echo_client.py b/examples/echo_client.py index 2fa5376..7e01c2e 100644 --- a/examples/echo_client.py +++ b/examples/echo_client.py @@ -215,8 +215,9 @@ async def encrypted_reply( xep_0384: XEP_0384 = self["xep_0384"] if isinstance(reply, str): + reply_body = reply reply = self.make_message(mto=mto, mtype=mtype) - reply["body"] = reply + reply["body"] = reply_body reply.set_to(mto) reply.set_from(self.boundjid)