I'm writing a client of telegram using Telethon. How can i get channel description? get_entity
method does not provide channel description.
How to get telegram's channel description in Telethon?
Asked Answered
There is GetFullChannelRequest method
from telethon.tl.functions.channels import GetFullChannelRequest
# creating client here
ch = client.get_entity("@mychannel")
ch_full = client(GetFullChannelRequest(channel=ch))
ch_full.full_chat.about # this is what you need
So you may want to inspect full_chat
attribute as it includes rest of info
Another example of usage with a bot
from telethon.sync import TelegramClient, events
from telethon import functions
bot = TelegramClient(
'bot', API_ID, API_HASH).start(bot_token=BOT_TOKEN)
@bot.on(events.NewMessage)
async def my_event_handler(event):
chat = await event.get_chat()
result = await bot(functions.messages.GetFullChatRequest(
chat_id=chat.id
))
print(result.full_chat.about)
bot.run_until_disconnected()
You have to use getChat method with chat_id
or @username
, and .result.description
is what you need.
Could you add some lines of code. Is
getChat
method of Channel
class? –
Holystone In fact, I didn't know how to use it in Python, it is Bot API method :( –
Riannon
© 2022 - 2024 — McMap. All rights reserved.
get_input_entity()
to reduce network requests by using caching. – Glovsky