如何使用 Telethon 创建公共(public)/私有(private) channel ?我在官方文档中没有找到这个信息。
最佳答案
您可以使用此过程来创建私有(private) channel (并通过为其分配用户名将其公开):
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))
关于python - 马拉松。如何创建公共(public)/私有(private) channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52160946/