【发布时间】:2022-01-24 21:53:29
【问题描述】:
我想创建一个机器人来将我的文本发布到频道... 谁能帮我写代码?
这是我尝试过的代码:
import telegram
token = "5002307835:AAGOu4f******************"
chat_id = "1382******"
bot = telegram.Bot(token)
def send_message(message):
return bot.send_message(chat_id,message)
send_message("HI")
但我收到此错误:telegram.error.BadRequest: Chat not found
我也试过了:chat_id = "-1382******" 和 chat_id = -1382****** 和 chat_id = 1382******
【问题讨论】:
-
你使用的是哪个模块?
-
我正在使用 Telegram 模块。
-
假设您使用的是
python-telegram-bot,您似乎使用的是旧格式,see
标签: python telegram telegram-bot python-telegram-bot py-telegram-bot-api