Telegram 机器人不发送消息
Telegram bot is not sending messages
我正在尝试执行这个简单的电报机器人,但我没有得到任何输出,我也不知道我做错了什么。这是代码:
from telegram import Update
from telegram.ext import Updater, CommandHandler, CallbackContext
def hello(update: Update, context: CallbackContext) -> None:
update.message.reply_text(f'Hello {update.effective_user.first_name}')
updater = Updater('my_token')
updater.dispatcher.add_handler(hello)
updater.start_polling()
updater.idle()
我想你在 add_handler
函数中遗漏了一些参数,所以它应该像下面这样:
updater.dispatcher.add_handler(CommandHandler('hello', hello))
我正在尝试执行这个简单的电报机器人,但我没有得到任何输出,我也不知道我做错了什么。这是代码:
from telegram import Update
from telegram.ext import Updater, CommandHandler, CallbackContext
def hello(update: Update, context: CallbackContext) -> None:
update.message.reply_text(f'Hello {update.effective_user.first_name}')
updater = Updater('my_token')
updater.dispatcher.add_handler(hello)
updater.start_polling()
updater.idle()
我想你在 add_handler
函数中遗漏了一些参数,所以它应该像下面这样:
updater.dispatcher.add_handler(CommandHandler('hello', hello))