gpt4 book ai didi

python - 马拉松。如何创建公共(public)/私有(private) channel ?

转载 作者:行者123 更新时间:2023-12-04 01:28:06 25 4
gpt4 key购买 nike

如何使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com