试图列出 chat_id

Trying to make a list of chat_id

我正在尝试为我的 Telegram 机器人制作一个 chat_id 的列表,这将允许我的机器人向列表中的所有 chat_id 发送一条消息。这是我试过的,

    listofids = ['191929390', '102938483']
    bot.sendMessage(listofids, str("worked"))

但是我遇到了这个错误

telepot.exception.TelegramError: ('Bad Request: chat not found', 400, {'ok': False, 'error_code': 400, 'description': 'Bad Request: chat not found'})

那么这里有什么问题以及如何解决这个问题?

chat_id semdMessage 方法的参数应该是 int,而不是 list 或其他可迭代的。

如果您希望将同一条短信发送给多个收件人,请循环执行:

listofids = [191929390, 102938483]  # int here

for recipient_id in listofids:
    bot.sendMessage(recipient_id, "worked")  # no str() needed