0

如何上传频道/聊天标志?我在官方文档中没有找到这个信息。

4

1 回答 1

2

您可以使用此代码更改频道的头像:

我使用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')
于 2018-09-13T18:31:44.790 回答