或
pyrogram
Python 库为 Telegram 上的公共频道运行GetMessagePublicForwards 函数。该功能应该允许“获取消息列表,指示频道消息转发到哪些其他公共频道”。
我无法理解该函数的输入是什么。此外,我很难获得公共电报频道的 access_hash 。我也将不胜感激在这方面的任何帮助(在这方面,我尝试了此链接上所说的内容,但没有成功)。
到目前为止我尝试过:
from pyrogram import Client
from pyrogram.raw import functions, types
api_id = MY_ID
api_hash = MY_HASH
async with Client("my_account", api_id, api_hash) as app:
chat_id = CHAT_ID # the channel id
message_id = MESSAGE_ID # message id
access_hash= ACCESS_HASH # for the public channel
channel = types.InputChannel(
channel_id=chat_id,
access_hash=access_hash)
offset_peer = types.InputPeerChannel(
channel_id=chat_id,
access_hash=access_hash)
r = await app.invoke(
functions.stats.GetMessagePublicForwards(
channel=channel,
msg_id=message_id,
offset_rate=1,
offset_peer=offset_peer,
offset_id=1,
limit=100))
print(r)
在热解图上或
from telethon.sync import TelegramClient
from telethon import functions, types
api_id = MY_ID
api_hash = MY_HASH
async with TelegramClient('me', api_id, api_hash) as client:
chat_id = CHAT_ID # the public channel
message_id = MESSAGE_ID # message id
access_hash= ACCESS_HASH # for the public channel
channel = types.InputChannel(
channel_id=chat_id,
access_hash=access_hash)
offset_peer = types.InputPeerChannel(
channel_id=chat_id,
access_hash=access_hash)
result = await client(functions.stats.GetMessagePublicForwardsRequest(
channel=channel,
msg_id=message_id,
offset_rate=42,
offset_peer=offset_peer,
offset_id=42,
limit=100
))
在电视马拉松上。
在这两种情况下,我都会收到错误:
Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group (caused by GetMessagePublicForwardsRequest)
对于电视马拉松,并且
ChannelInvalid: Telegram says: [400 CHANNEL_INVALID] - The channel parameter is invalid (caused by "stats.GetMessagePublicForwards")
用于热解图。
这让我怀疑我的代码有问题,因为该频道是公共的。此外,我知道here人们可以找到我正在寻找的相同信息,这让我认为我的代码应该适用于该功能(否则必须解释如何在 TgStat 中获得此类信息)。
有人用过这个功能吗?他们可以帮助我了解我的代码中是否存在任何错误吗?
更有可能的是,您在尝试查询的频道中缺乏足够的权限。可能还有其他限制(例如参与者数量或通道设置方式)会导致问题,但 Telegram 可能会重复使用相同的错误代码(这让我们感到困惑)。
stats.getMessagePublicForwards
的官方文档并没有说更多。
使用您的代码作为我的解决方案的基础,没有得到公开转发,但是当我更改
offset_rate=0
和offset_id=0
时,它开始按预期工作