Вы можете использовать этот код для изменения аватара канала:
я использую EditPhotoRequest
, InputChatUploadedPhoto
для изменения аватара моего канала ( test_ali3 ).
from telethon import TelegramClient, events, sync
from telethon.tl.functions.channels import EditPhotoRequest
from telethon.tl.types import InputChatUploadedPhoto
api_id = XXXXXX
api_hash = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
phone_number = '+989XXXXXXXXX'
################################################
channel_username = "test_ali3"
################################################
client = TelegramClient('session_name',
api_id,
api_hash,
)
client.start()
channel_entity = client.get_entity(channel_username)
upload_file_result = client.upload_file(file='images/amnesic98.jpg')
input_chat_uploaded_photo = InputChatUploadedPhoto(upload_file_result)
try:
result = client(EditPhotoRequest(channel=channel_entity,
photo=input_chat_uploaded_photo))
except BaseException as e:
print(e)
print('finish')