Как получить владельца чата через Telethon?
Возможно ли узнать id
владельца чата через Telethon?
Источник: Stack Overflow на русском
Возможно ли узнать id
владельца чата через Telethon?
from telethon.tl.types import ChannelParticipantsAdmins
from telethon.tl.types import ChannelParticipantCreator
import typing
async def get_owner_id(
chat_id: int # id чата, в котором нужно получить владельца
) -> typing.Union[int, bool]:
owner_id = False
async for user in client.iter_participants(
chat_id, filter=ChannelParticipantsAdmins
):
if isinstance(getattr(user, 'participant', None),
ChannelParticipantCreator
):
return user.participant.user_id
return owner_id