繁体   English   中英

如何在 Telegram with Telethon 上创建具有使用限制的邀请到私人频道?

[英]How do I create invites with usage limit to a private channel on Telegram with Telethon?

我正在使用Telethon创建 Telegram BOT,我需要自动生成一次性使用邀请的任务

我尝试搜索它,但在他们的文档中也没有找到任何东西,也没有在 stackoverflow 中找到任何东西(我确实找到了关于这个库的邀请,但不明白如何处理我的情况)

欢迎任何可以帮助我的东西!!

先感谢您!

telethon.dev ,您可以修改示例,例如:

from telethon.sync import TelegramClient
from telethon import functions, types

session_file_name = ""        # TODO session file name without extension
api_id = ""                   # TODO api id 
api_hash = ""                 # TODO api hash 
channel_id = -1001109500936   # TODO channel ID 

with TelegramClient(session_file_name, api_id, api_hash) as client:
    result = client(functions.messages.ExportChatInviteRequest(
        peer=client.get_input_entity(channel_id),
        legacy_revoke_permanent=True,
        expire_date=None, # Set expiry date if needed like datetime.datetime(2018, 6, 25),
        usage_limit=1     # Only one person can use your invite link
    ))
    print(result.stringify())

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM