电视节目。如何创建公共/私人频道?

str*_*k-j 3 python python-3.x telegram telethon

如何使用 Telethon 创建公共/私人频道?我在官方文档中没有找到这个信息。

tas*_*ori 6

您可以使用此过程来创建私人频道(也可以通过为它们分配用户名来将它们设为公开):

from telethon.tl.functions.channels import CreateChannelRequest, CheckUsernameRequest, UpdateUsernameRequest
from telethon.tl.types import InputChannel, InputPeerChannel
createdPrivateChannel = client(CreateChannelRequest("title","about",megagroup=False))

#if you want to make it public use the rest
newChannelID = createdPrivateChannel.__dict__["chats"][0].__dict__["id"]
newChannelAccessHash = createdPrivateChannel.__dict__["chats"][0].__dict__["access_hash"]
desiredPublicUsername = "myUsernameForPublicChannel"
checkUsernameResult = client(CheckUsernameRequest(InputPeerChannel(channel_id=newChannelID, access_hash=newChannelAccessHash), desiredPublicUsername))
if(checkUsernameResult==True):
    publicChannel = client(UpdateUsernameRequest(InputPeerChannel(channel_id=newChannelID, access_hash=newChannelAccessHash), desiredPublicUsername))
Run Code Online (Sandbox Code Playgroud)