请帮我解决在地图上写机器人的问题。其本质如下所示。有一个设置菜单,你可以从显示的列表中选择一种货币(我会在下面附上一个截图)。当您单击任何按钮时,所选货币的值应传递到通常的菜单按钮。如果您能举个例子,我将不胜感激,或者告诉我应该朝哪个方向发展。最后,您应该得到BTC/RUB、BTC/KZT等。

代码处理程序:
@dp.message_handler(Command(commands=['set']))
async def setting_menu(message: types.Message):
await message.answer("⚙ Settings", reply_markup=staye)
await message.answer(f"{message.from_user.first_name}, you are in the settings.\n\n"
f"Select the currency of interest in the menu below.\n"
reply_markup=set_menu)代码内联键盘:
set_menu = InlineKeyboardMarkup(row_width=1,
inline_keyboard=[
[
InlineKeyboardButton(
text="RUB",
callback_data='1'
),
InlineKeyboardButton(
text="UAH",
callback_data='2'
),
InlineKeyboardButton(
text="USD",
callback_data='3'
),
InlineKeyboardButton(
text="KZT",
callback_data='4'
),
InlineKeyboardButton(
text="BYN",
callback_data='5'
),
]
])默认键盘代码:
staye = ReplyKeyboardMarkup(row_width=2, resize_keyboard=True)
course = KeyboardButton(text="BTC/....")
course1 = KeyboardButton(text="test1")
course2 = KeyboardButton(text="test2")
staye.add(course, course1, course2)发布于 2021-08-27 22:38:36
用户单击内联按钮(RUB、USD等)后,您应该使用新的ReplyMarkup发送消息。没有任何方法可以在不发送新消息或编辑现有消息的情况下更改键盘文本,以实现不同的键盘文本,您可以这样做
def get_reply_markup(currency: str) -> ReplyKeyboardMarkup:
staye = ReplyKeyboardMarkup(row_width=2, resize_keyboard=True)
course = KeyboardButton(text=currency)
course1 = KeyboardButton(text="test1")
course2 = KeyboardButton(text="test2")
staye.add(course, course1, course2)这个“货币”可以从内联键盘回调中获得。在那之后:
@dp.callback_query_handler(*Your filtering*)
async def handler(call: types.CallbackQuery, callback_data: dict):
currency = callback_data.get('currency')
keyboard = get_reply_markup(currency)
await call.message.answer(text='Some text', reply=keyboard)
await call.answer()https://stackoverflow.com/questions/68913435
复制相似问题