From ce0c525973244fb21358c374a3f739fb04964925 Mon Sep 17 00:00:00 2001 From: uak <4626956-uak@users.noreply.gitlab.com> Date: Mon, 30 Sep 2024 08:55:39 +0300 Subject: [PATCH] Replaced depreicated reply_to_message_id --- examples/asynchronous_telebot/custom_states.py | 17 ++++++++++------- examples/custom_states.py | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/examples/asynchronous_telebot/custom_states.py b/examples/asynchronous_telebot/custom_states.py index f0111e27e..f3437660f 100644 --- a/examples/asynchronous_telebot/custom_states.py +++ b/examples/asynchronous_telebot/custom_states.py @@ -2,6 +2,7 @@ from telebot.asyncio_storage import StateMemoryStorage from telebot.states import State, StatesGroup from telebot.states.asyncio.context import StateContext +from telebot.types import ReplyParameters # Initialize the bot state_storage = StateMemoryStorage() # don't use this in production; switch to redis @@ -23,7 +24,7 @@ async def start_ex(message: types.Message, state: StateContext): await bot.send_message( message.chat.id, "Hello! What is your first name?", - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -34,7 +35,7 @@ async def any_state(message: types.Message, state: StateContext): await bot.send_message( message.chat.id, "Your information has been cleared. Type /start to begin again.", - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -43,7 +44,8 @@ async def any_state(message: types.Message, state: StateContext): async def name_get(message: types.Message, state: StateContext): await state.set(MyStates.age) await bot.send_message( - message.chat.id, "How old are you?", reply_to_message_id=message.message_id + message.chat.id, "How old are you?", + reply_parameters=ReplyParameters(message_id=message.message_id), ) await state.add_data(name=message.text) @@ -64,7 +66,7 @@ async def ask_color(message: types.Message, state: StateContext): message.chat.id, "What is your favorite color? Choose from the options below.", reply_markup=keyboard, - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -84,7 +86,7 @@ async def ask_hobby(message: types.Message, state: StateContext): message.chat.id, "What is one of your hobbies? Choose from the options below.", reply_markup=keyboard, - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -123,7 +125,8 @@ async def finish(message: types.Message, state: StateContext): ) await bot.send_message( - message.chat.id, msg, parse_mode="html", reply_to_message_id=message.message_id + message.chat.id, msg, parse_mode="html", + reply_parameters=ReplyParameters(message_id=message.message_id), ) await state.delete() @@ -134,7 +137,7 @@ async def age_incorrect(message: types.Message): await bot.send_message( message.chat.id, "Please enter a valid number for age.", - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) diff --git a/examples/custom_states.py b/examples/custom_states.py index 131dd1d42..e1bf13295 100644 --- a/examples/custom_states.py +++ b/examples/custom_states.py @@ -3,6 +3,7 @@ from telebot.states import State, StatesGroup from telebot.states.sync.context import StateContext from telebot.storage import StateMemoryStorage +from telebot.types import ReplyParameters # Initialize the bot state_storage = StateMemoryStorage() # don't use this in production; switch to redis @@ -24,7 +25,7 @@ def start_ex(message: types.Message, state: StateContext): bot.send_message( message.chat.id, "Hello! What is your first name?", - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -35,7 +36,7 @@ def any_state(message: types.Message, state: StateContext): bot.send_message( message.chat.id, "Your information has been cleared. Type /start to begin again.", - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -44,7 +45,8 @@ def any_state(message: types.Message, state: StateContext): def name_get(message: types.Message, state: StateContext): state.set(MyStates.age) bot.send_message( - message.chat.id, "How old are you?", reply_to_message_id=message.message_id + message.chat.id, "How old are you?", + reply_parameters=ReplyParameters(message_id=message.message_id), ) state.add_data(name=message.text) @@ -65,7 +67,7 @@ def ask_color(message: types.Message, state: StateContext): message.chat.id, "What is your favorite color? Choose from the options below.", reply_markup=keyboard, - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -85,7 +87,7 @@ def ask_hobby(message: types.Message, state: StateContext): message.chat.id, "What is one of your hobbies? Choose from the options below.", reply_markup=keyboard, - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), ) @@ -124,7 +126,8 @@ def finish(message: types.Message, state: StateContext): ) bot.send_message( - message.chat.id, msg, parse_mode="html", reply_to_message_id=message.message_id + message.chat.id, msg, parse_mode="html", + reply_parameters=ReplyParameters(message_id=message.message_id), ) state.delete() @@ -135,7 +138,7 @@ def age_incorrect(message: types.Message): bot.send_message( message.chat.id, "Please enter a valid number for age.", - reply_to_message_id=message.message_id, + reply_parameters=ReplyParameters(message_id=message.message_id), )