Как можно изменить ссылку собственного канала или другую либо информацию?
1 ответ
from telethon import sync, TelegramClient
from telethon.tl.functions.channels import GetChannelsRequest, CheckUsernameRequest, UpdateUsernameRequest
from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.types import InputChannel, InputPeerChannel
from config import *
client = TelegramClient('anon', API_ID, API_HASH)
with client:
cur_chan_username = '*********'
response = client(ResolveUsernameRequest(cur_chan_username))
createdPrivateChannel = GetChannelsRequest(InputChannel(cur_chan_username, response.chats[0].access_hash))
newChannelID = response.chats[0].id
newChannelAccessHash = response.chats[0].access_hash
desiredPublicUsername = "new chan username"
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))