fritsimeel
fritsimeel

Reputation: 25

Telegram retrieving groupname by user id

I'm using telethon GetFullUserRequest to retrieve user id and name.
I want to see if this user id is a member of a group, or even a member of multiple groups.
I googled but I can't find a solution.

Is this possible, and if yes, how?

Regards and thanks in advance.

Upvotes: 0

Views: 688

Answers (1)

Lonami
Lonami

Reputation: 7086

As @go2nirvana pointed out, you can get the common chats, but that's all you can do (there is simply no way to know which broadcast channels they're in, or what groups unless you're in them too).

This is done with GetCommonChatsRequest and is what clients show as "groups in common" when you open someone's profile:

async def main():
    result = await client(functions.messages.GetCommonChatsRequest(
        user_id='username',
        max_id=0,
        limit=100
    ))

    for chat in result.chats:
        ...

Upvotes: 1

Related Questions