如何在电报机器人中创建 "method"
How to create a "method" in a telegram bot
您好,我正在尝试创建一个机器人来自动执行亚马逊搜索,我希望它使用起来非常简单。
我希望它在您创建新机器人时表现得像 BotFather:
Ask for Bot name
Input and get bot name
Ask for bot tag
Input and get bot tag
Create bot
不知从何说起
目前完成的代码:
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
我建议您查看图书馆 python-telegram-bot and their very informative wiki. The code samples include one for a conversation bot,这听起来像您所描述的
您好,我正在尝试创建一个机器人来自动执行亚马逊搜索,我希望它使用起来非常简单。 我希望它在您创建新机器人时表现得像 BotFather:
Ask for Bot name
Input and get bot name
Ask for bot tag
Input and get bot tag
Create bot
不知从何说起
目前完成的代码:
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
我建议您查看图书馆 python-telegram-bot and their very informative wiki. The code samples include one for a conversation bot,这听起来像您所描述的