python - Telegram 通过 API 和 Python 向其他组发送消息错误:****
问题描述
我需要帮助解决以下问题。我正在尝试编写一个脚本,将广告发送到我所属的多个 Telegram 组。这些组是为广告而制作的,我可以向这些组发送消息。
每次我运行脚本时,我都会收到以下错误:
<class 'telethon.errors.rpcerrorlist.ChatWriteForbiddenError'>
那是我的代码:
import sys
from telethon import TelegramClient
import time
import datetime
starttime=time.time()
#Unsere API_ID und API_Hash
api_id=******
api_hash='******************'
TestGroup=['Name of Group']
textgroups= 'Thats the Text'
failcount=0,
while True:
with TelegramClient('anon', api_id, api_hash) as client:
for x in TestGroup:
try:
client.loop.run_until_complete(client.send_message(x, textgroups))
except:
print(x, sys.exc_info()[0])
failcount +=1
print(datetime.datetime.now(), str(failcount/len(groups)*100)+ '%')
time.sleep(120)
解决方案
推荐阅读
- button - 在 Jupyter 中使用按钮计算输出
- javascript - 与对象中的值匹配时的 QuerySelector Id 目标
- react-native - 无法对未安装的组件执行 React 状态更新。(react-native-error)
- python - 如何使用 lambda 函数将当前列表索引与下一个列表索引进行比较
- sql - 左表中空记录的子查询问题
- android - 工具栏中的菜单更改或消失
- authentication - 在 Linux 下使用 curl 到 FTPS 到 z/OS FTP TLS 服务器与客户端身份验证
- javascript - render() 是如何实际执行的?
- blazor - Mapster 和 Blazor
- build - Bamboo 构建后自动删除工件的脚本