如何在电报机器人中创建“方法”

问题描述

您好,我正在尝试创建一个自动执行亚马逊搜索的机器人,我希望它使用起来非常简单。 我希望它在创建新的bot时像BotFather一样起作用:

询问机器人名称

输入并获取机器人名称

询问机器人标记

输入并获取机器人标记

创建机器人

我不知道从哪里开始

到目前为止,

代码已完成:

keyboard=  types.ReplyKeyboardMarkup(row_width=1)
help_btn =  types.KeyboardButton('Aiuto')
min_price = types.KeyboardButton('Prezzominimo')
max_price = types.KeyboardButton('Prezzomassimo')
range_price = types.KeyboardButton('Range') 
keyboard.row(min_price)
keyboard.row(max_price)
keyboard.row(range_price)
keyboard.row(help_btn)














bot = telebot.AsyncTeleBot(TOKEN,'HTML')

if bot_is_active:

@bot.message_handler(commands=["start"])
def main_menu(message):
    bot.send_message(message.chat.id,"Benvenuto,questo bot ti permette di cercare articoli su Amazon",reply_markup=keyboard)
pass



@bot.message_handler(func=lambda message:True)
def kb1_handler(message):
    if message.text == 'Aiuto':
        bot.send_message(message.chat.id,Help message)    
    elif message.text == 'Range':
        bot.send_message(message.chat.id,"Cosa cerchi?")
        #range_set = True
    elif message.text == 'Prezzominimo':
        bot.send_message(message.chat.id,"Cosa cerchi?")
        min_set = True
    else:
        bot.send_message(message.chat.id,"Cosa cerchi?")
        #max_set = True
    pass

    if min_set:
        bot.send_message(message.chat.id,"trovato")

pass

docs:https://github.com/eternnoir/pyTelegramBotAPI

解决方法

我建议您检阅库python-telegram-bot及其非常有用的Wiki。这些代码示例包含一个conversation bot的代码,听起来像您在描述

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...