如何解决具有多级菜单的 Telegram Bot 无需发送消息
有人可以帮忙吗,我不明白如何用两个菜单来做我的机器人。 首先 - 是“短菜单”,您可以在其中按下按钮并打开具有所有功能的“长菜单” 第二 - 在“长菜单”菜单中,我拥有所有功能和“返回菜单”按钮。 我无法理解如何制作让我回到“短菜单”的“返回菜单”按钮 请帮帮我。而 Main -- 点击按钮不应该向用户发送消息
def telegram():
with open("madata") as f3:
info = yaml.safe_load(f3)
token = mytoken
bot = Bot(token=token)
dp = Dispatcher(bot)
#greeting message,pin this message in private chat
@dp.message_handler(commands=['start'])
async def greeting(message: types.Message):
chat_id = message.chat.id
msg = '''hello friend'''
# body of keyboard
small_function = ReplyKeyboardMarkup(
keyboard = [
[
KeyboardButton(text="show functions",callback_data='open menu all functions')
]
],resize_keyboard=True
)
all_functions = ReplyKeyboardMarkup(
keyboard = [
[
KeyboardButton(text="function 1",callback_data='do function1')
],[
KeyboardButton(text="function 2",callback_data='do function2')
],[
KeyboardButton(text="back to menu",callback_data=' open menu small_function')
],],resize_keyboard=True
)
#insert my keyboard
sent_message = await bot.send_message(chat_id=chat_id,text=msg,parse_mode = "Markdown",reply_markup=small_function)
print(sent_message.message_id)
@bot.callback_query_handler(func=lambda call: True)
async def answer(call):
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。