python - 从 stats channel request api telegram 获取数据
问题描述
我想从电报 api 获取统计数据通道。我编写并运行此代码,但收到错误: telethon.errors.rpcerrorlist.ChatAdminRequiredError:在指定的聊天中执行此操作需要聊天管理员权限(例如,在不属于您的频道中发送消息),或无效用于频道或组的权限(由 GetBroadcastStatsRequest 引起) 请帮我检查并修复它。非常感谢 !p/s: 这是我的频道
import configparser
from telethon.tl.types import ChannelParticipantsSearch
from telethon.tl.functions.channels import GetFullChannelRequest
from telethon import functions, types
from telethon.tl.functions.stats import GetBroadcastStatsRequest
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
from telethon.tl.types import InputChannel
config = configparser.ConfigParser()
config.read("config.ini")
api_id = config['Telegram']['api_id']
api_hash = config['Telegram']['api_hash']
api_hash = str(api_hash)
phone = config['Telegram']['phone']
username = config['Telegram']['username']
channel = 'https://t.me/testapi2607'
id_channel = 1523534046
access_hash = 7456721436474437
client = TelegramClient(username, api_id, api_hash)
async def main():
await client.start()
print("Client Created")
# Ensure you're authorized
if await client.is_user_authorized() == False:
await client.send_code_request(phone)
try:
await client.sign_in(phone, input('Enter the code: '))
except SessionPasswordNeededError:
await client.sign_in(password=input('Password: '))
me = await client.get_me()
await client.get_entity(PeerChannel(1523534046))
my_channel = InputChannel(id_channel, access_hash)
result = await client(functions.stats.GetBroadcastStatsRequest(channel = my_channel, dark=True))
print(str(result))
with client:
client.loop.run_until_complete(main())```
解决方案
推荐阅读
- node.js - 是否可以写入 nodejs 标准输出以使接收的 nodejs 标准输入“on-data”返回单个段?
- php - 将 PHP mssql 更改为 sqlsrv (mssql_fetch_row)
- javascript - 令牌拦截器不再发送原始请求(Angular、Node.js)
- jenkins - 请求中没有包含有效的面包屑 - Jenkins 403
- google-chrome-devtools - Chrome DevTools 性能布局缺少代码参考
- swift - Swift 5 RxDataSource 可扩展单元格
- ruby - Codekit 文件权限问题(只读文件系统 @ dir_s_mkdir - /.sass-cache)
- pandas - 熊猫时间序列的 interp1d
- android - 如何覆盖片段中的浮动操作按钮?
- javascript - React Router Link 更改 URL 但未查看