python - 尝试列出 chat_id
问题描述
我正在尝试chat_id
为我的 Telegram 机器人制作一个列表,这将允许我的机器人向列表中的所有人发送一条消息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
推荐阅读
- numpy - `np.random.seed(number)` 中括号中的数字是什么意思?
- javascript - 如何将查询数据添加到数组
- unity3d - CommandInvokationFailure:Gradle 构建失败。关于团结
- sql - 如何从一个“表”连接多个表在同一个自动生成的整数上?
- sql - Oracle - 如何转换由 NUMBER(6,0) 格式表示的日期
- shacl - 如何根据 shacl 的使用来验证类的实例?
- javascript - 仅在验证凭据后,如何为 html 按钮“onclick="location.href=''" 进行用户登录?
- git - 在对 master 运行 git diff 时,有没有办法获取文件的根目录路径?
- python - 如何从文本中读取特定世界的文本告诉python中文本文件中的下一个空格
- apache-spark - 如何在 scala 中对数据框中的多个列进行 mapreduce?