【发布时间】:2021-12-20 16:09:10
【问题描述】:
我正在开发一个电报机器人。我在我的代码上执行此操作,问题是,为什么我的机器人在我输入第二个命令时会重复相同的第一个短语?
TOKEN_BOT = "secret token"
bot = telebot.TeleBot(TOKEN_BOT)
@bot.message_handler(commands=["hello", "start"])
def send(message):
bot.reply_to(message, "Welcome, I am RIOPy! BOT designed to organize your SME to your liking. To start write / start and we will get to work.")
bot.polling()
def enviar_start (message):
bot.reply_to(message, "Great! wait 5 seconds.")
#HERE DATABASE CODE
time.sleep(5)
bot.reply_to, "DATABASE CREATED"
bot.polling()
PS:代码现在可以工作了。我删除了 if 下的 bot.pulling(),并将 /hello 和 /start 命令放在了 2 个不同的行中。
@bot.message_handler(commands=["hello"])
def send(message):
bot.reply_to(message, "Welcome, I am RIOPy! BOT designed to organize your SME to your liking. To start write / start and we will get to work.")
@bot.message_handler(commands=["start"])
def enviar_start (message):
bot.reply_to(message, "Great! wait 5 seconds.")
【问题讨论】:
标签: python py-telegram-bot-api