【发布时间】:2021-09-10 11:30:06
【问题描述】:
我正在使用pytelegrambotapi 创建一个 Telegram 机器人。但是当我测试代码时,我的 Telegram Bot 总是回复引用我的输入 like this,我不希望它引用我的输入消息而是直接发送消息。
另外我怎样才能通过使用简单的Hi 或Hello 而不是/hi 或/hello 来获得回复。
我的代码:
import telebot
import time
bot_token = ''
bot= telebot.TeleBot(token=bot_token)
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message, 'Hi')
@bot.message_handler(commands=['help'])
def send_welcome(message):
bot.reply_to(message, 'Read my description')
while True:
try:
bot.polling()
except Exception:
time.sleep(10)
【问题讨论】:
-
我猜 reply_to 这样做是为了表明它正在回复什么消息。也许尝试 bot.send_message(message.chat.id, “Hi”) 回复频道而不是消息?
标签: bots telegram php-telegram-bot py-telegram-bot-api telegram-api