【问题标题】:How do I create invites with usage limit to a private channel on Telegram with Telethon?如何在 Telegram with Telethon 上创建具有使用限制的邀请到私人频道?
【发布时间】:2022-01-13 15:39:59
【问题描述】:

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

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

欢迎任何对我有帮助的东西!!

提前谢谢你!

【问题讨论】:

    标签: python bots telegram telethon


    【解决方案1】:

    来自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())
    

    【讨论】:

      猜你喜欢
      • 2022-07-17
      • 2020-05-18
      • 2020-11-01
      • 1970-01-01
      • 2021-01-25
      • 1970-01-01
      • 2018-10-14
      • 2017-11-14
      • 1970-01-01
      相关资源
      最近更新 更多