![](/img/trans.png)
[英]How can I send messages to my private telegram channel with Telethon?
[英]How do I create invites with usage limit to a private channel on Telegram with Telethon?
从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.