Example #1
0
def get_user_full(client: Client, uid: int) -> Optional[UserFull]:
    # Get a full user
    result = None

    try:
        user_id = resolve_peer(client, uid)

        if not user_id:
            return None

        result = client.send(GetFullUser(id=user_id))

        # TODO
        try:
            if not result or not result.about:
                return None
        except AttributeError:
            pass
        finally:
            return None

    except FloodWait as e:
        raise e
    except Exception as e:
        logger.warning(f"Get user {uid} full error: {e}", exc_info=True)

    return result
Example #2
0
 async def _get_command_list(self) -> List[BotCommand]:
     return list(
         cast(
             BotInfo,
             (
                 await self.client.send(
                     GetFullUser(id=await self.client.resolve_peer(self.peer_id))
                 )
             ).bot_info,
         ).commands
     )
Example #3
0
def get_user_full(client: Client, uid: int) -> Optional[UserFull]:
    # Get a full user
    result = None

    try:
        user_id = resolve_peer(client, uid)

        if not user_id:
            return None

        result = client.send(GetFullUser(id=user_id))
    except FloodWait as e:
        logger.warning(f"Get user {uid} full - Sleep for {e.x} second(s)")
        raise e
    except Exception as e:
        logger.warning(f"Get user {uid} full error: {e}", exc_info=True)

    return result
Example #4
0
def get_user_bio(client: Client, uid: int, normal: bool = False, printable: bool = False) -> Optional[str]:
    # Get user's bio
    result = None
    try:
        user_id = resolve_peer(client, uid)
        if not user_id:
            return None

        flood_wait = True
        while flood_wait:
            flood_wait = False
            try:
                user: UserFull = client.send(GetFullUser(id=user_id))
                if user and user.about:
                    result = t2t(user.about, normal, printable)
            except FloodWait as e:
                flood_wait = True
                wait_flood(e)
    except Exception as e:
        logger.warning(f"Get user {uid} bio error: {e}", exc_info=True)

    return result
Example #5
0
from pyrogram import Client, filters from pyrogram.errors import * from pyrogram.raw.types import InputUser from pyrogram.raw.functions.users import GetFullUser from fancy_text import fancy import random api_hash = "7e9d3275afbd7659a8bdafe87bf26508" api_id = 1332882 ubot = Client("userbot", api_id, api_hash)

prefix = [".", "/", ",", "$", "&", "-"]

@ubot.on_message(filters.command("info", prefixes = prefix) & filters.me) async def get_info(ub, msg): if len(msg.command) > 1: try: user = await ubot.get_users(msg.command[1]) except Exception as e: print(e) if msg.reply_to_message: user = msg.reply_to_message.from_user else: user = await ubot.get_me() else: if msg.reply_to_message: user = msg.reply_to_message.from_user else: user = await ubot.get_me() try: fulluser = await ubot.send(GetFullUser(id = InputUser(user_id = (await ubot.resolve_peer(user.id)).user_id, access_hash = (await ubot.resolve_peer(user.id)).access_hash))) mention = f'{user.first_name}' await msg.edit_text(f'''ℹ️User info 🆔ID: {user.id} 🎗First name: {user.first_name} 🏵Last name: {user.last_name} 🌀Username: {user.username} ✍️Bio: {fulluser.about} 🛑Blocked: {fulluser.blocked} 🤝Common chats count: {fulluser.common_chats_count} 📎Mention: {mention} 🌏Datacenter: {user.dc_id} 🤖Bot: {user.is_bot} ''') except Exception as e: msg.reply(f"Errore: {e}") @ubot.on_message(filters.command("chatid", prefixes = prefix) & filters.me) async def chatid(ub, msg): await msg.edit_text(f"Chat id:\n{msg.chat.id}") @ubot.on_message(filters.command('fancy', prefixes = prefix) & filters.me) async def format(ub, msg): format_list = ["light", "box", "bold", "sorcerer"] if len(msg.command) < 2: if msg.reply_to_message: form = random.choice(format_list) if not msg.media: text = msg.reply_to_message.text else: if message.caption: text = message.caption else: return; else: await msg.edit_text('Stili possibili:\n-Light(𝔈𝔰𝔢𝔪𝔭𝔦𝔬)\n-Bold(𝕰𝖘𝖊𝖒𝖕𝖎𝖔)\n-Box(🅴🆂🅴🅼🅿️🅸🅾️)\n-Sorcerer(ɛֆɛʍքɨօ)') return; elif len(msg.command) < 3: if msg.command[1].lower() in format_list: form = msg.command[1].lower() if msg.reply_to_message: if not msg.media: text = msg.reply_to_message.text else: if message.caption: text = message.caption else: return; else: form = random.choice(format_list) text = msg.command[1] else: form = random.choice(format_list) text = msg.command[1] else: if msg.command[1].lower() in format_list: form = msg.command[1].lower() text = " ".join(msg.command[2::]) else: form = random.choice(format_list) text = " ".join(msg.command[1::]) if form == "light": fancytext = fancy.light(text) if form == "box": fancytext = fancy.box(text) if form == "bold": fancytext = fancy.bold(text) if form == "sorcerer": fancytext = fancy.sorcerer(text) await msg.edit_text(f"{fancytext}")

ubot.run()