From f526a9d8a4def9dd8ba435af836c558534f92589 Mon Sep 17 00:00:00 2001 From: m-cyx <62351148+m-cyx@users.noreply.github.com> Date: Sun, 15 May 2022 22:46:15 +0300 Subject: [PATCH] Small srtring formatter fix --- examples/custom_states.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/custom_states.py b/examples/custom_states.py index 2f9a2bc..72c96df 100644 --- a/examples/custom_states.py +++ b/examples/custom_states.py @@ -60,7 +60,7 @@ def name_get(message): """ State 1. Will process when user's state is MyStates.name. """ - bot.send_message(message.chat.id, f'Now write me a surname') + bot.send_message(message.chat.id, 'Now write me a surname') bot.set_state(message.from_user.id, MyStates.surname, message.chat.id) with bot.retrieve_data(message.from_user.id, message.chat.id) as data: data['name'] = message.text @@ -83,7 +83,11 @@ def ready_for_answer(message): State 3. Will process when user's state is MyStates.age. """ with bot.retrieve_data(message.from_user.id, message.chat.id) as data: - bot.send_message(message.chat.id, "Ready, take a look:\nName: {name}\nSurname: {surname}\nAge: {age}".format(name=data['name'], surname=data['surname'], age=message.text), parse_mode="html") + msg = ("Ready, take a look:\n" + f"Name: {data['name']}\n" + f"Surname: {data['surname']}\n" + f"Age: {message.text}") + bot.send_message(message.chat.id, msg, parse_mode="html") bot.delete_state(message.from_user.id, message.chat.id) #incorrect number @@ -99,4 +103,4 @@ def age_incorrect(message): bot.add_custom_filter(custom_filters.StateFilter(bot)) bot.add_custom_filter(custom_filters.IsDigitFilter()) -bot.infinity_polling(skip_pending=True) \ No newline at end of file +bot.infinity_polling(skip_pending=True)