有没有办法通过 telethon 将文件发送到电报组中的特定主题?

问题描述 投票:0回答:1

我有一个脚本可以检测每次我用皮影戏制作剪辑时的情况。我想让它把特定主题的视频发送到我的电报群。

我能够得到的关闭是使用此代码发送到“常规”主题

from telethon.sync import TelegramClient

api_id = ''
api_hash = ''
group_id = ''
topic_name = ''

with TelegramClient('anon', api_id, api_hash) as client:
    client.send_file(group_id, 'test.jpg')

但我想这样做,以便将文件发送到确定的主题。在他们的变更日志(v1.26)中,他们似乎现在应该接受主题。

python telethon
1个回答
0
投票

一定有这样的参数

to_peer=dest_id, top_msg_id=dest_topic_id

其中 top_msg_id 是主题 id,如果您复制主题内消息的链接即可获取它,它看起来像“https://t.me/chanel_id/topic_id/message_id”

id 必须写为整数,而不是字符串

© www.soinside.com 2019 - 2024. All rights reserved.