Search code examples
pythontelegrampyrogram

How to take a bio with a pyrogram


import asyncio
from pyrogram import Client
from pyrogram.raw import functions

api_id = 
api_hash = ""
TARGET = -


app = Client("my_account")
async def main():
    async with app:
        # для парсинга группы
        async for member in app.get_chat_members(TARGET):
            print(member)
            break
app.run(main())

This code parses the group into users But when I parsed there is no user bio

{
    "_": "ChatMember",
    "status": "ChatMemberStatus.MEMBER",
    "user": {
        "_": "User",
        "id": ,
        "is_self": false,
        "is_contact": false,
        "is_mutual_contact": false,
        "is_deleted": false,
        "is_bot": false,
        "is_verified": false,
        "is_restricted": false,
        "is_scam": false,
        "is_fake": false,
        "is_support": false,
        "is_premium": false,
        "first_name": "",
        "status": "UserStatus.RECENTLY",
        "dc_id": 2,
        "photo": {
            "_": "ChatPhoto",
            "small_file_id": "AQADAgADJL8xG4zb8EgAEAIAA8e130cBAAPa3NiUo0I8QwAEHgQ",
            "small_photo_unique_id": "AgADJL8xG4zb8Eg",
            "big_file_id": "AQADAgADJL8xG4zb8EgAEAMAA8e130cBAAPa3NiUo0I8QwAEHgQ",
            "big_photo_unique_id": "AgADJL8xG4zb8Eg"
        }
    },
    "joined_date": "2022-09-12 14:43:27"

Everything except bio How can I find the bio preferably using id

You can even at a telethon if you want the main thing is that he takes a bio with the help of Id


Solution

  • Pyrogram's User object doesn't have a .bio, .about or similar.

    You'll want to get a Chat object via get_chat().
    Alternatively you could invoke() the lower level ("Raw") method users.GetFullUser() to get a raw.base.users.UserFull constructor, in which .full_user is the needed raw.types.UserFull. That last object has an .about, which will be the bio of the user.

    For more info on lower level / "Raw" methods, see Pyrogram's Documentation on Advanced Usage.