Ejemplo n.º 1
0
async def _(event):
    if event.fwd_from:
        return
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        await event.edit(str(error_i_a))
        return False
    replied_user_profile_photos = await borg(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "NaN"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError as e:
        pass
    user_id = replied_user.user.id
    # some people have weird HTML in their names
    first_name = html.escape(replied_user.user.first_name)
    # https://stackoverflow.com/a/5072031/4723940
    # some Deleted Accounts do not have first_name
    if first_name is not None:
        # some weird people (like me) have more than 4096 characters in their names
        first_name = first_name.replace("\u2060", "")
    # inspired by https://telegram.dog/afsaI181
    user_bio = replied_user.about
    if user_bio is not None:
        user_bio = html.escape(replied_user.about)
    common_chats = replied_user.common_chats_count
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "Need a Profile Picture to check **this**"
        location = str(e)
    caption = """Profile Pic Grabber By @ranger_op

Person: <a href='tg://user?id={}'>{}</a>
""".format(user_id, user_id, first_name, user_bio, dc_id,
           replied_user_profile_photos_count, replied_user.user.restricted,
           replied_user.user.verified, replied_user.user.bot, common_chats)
    message_id_to_reply = event.message.reply_to_msg_id
    if not message_id_to_reply:
        message_id_to_reply = event.message.id
    await borg.send_message(event.chat_id,
                            caption,
                            reply_to=message_id_to_reply,
                            parse_mode="HTML",
                            file=replied_user.profile_photo,
                            force_document=False,
                            silent=True)
    await event.delete()
Ejemplo n.º 2
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(
            user_id=replied_user.user.id, offset=42, max_id=0, limit=80
        )
    )
    replied_user_profile_photos_count = "User haven't set profile pic"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Couldn't fetch DC ID!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(
        user_id, TEMP_DOWNLOAD_DIRECTORY + str(user_id) + ".jpg", download_big=True
    )
    first_name = (
        first_name.replace("\u2060", "")
        if first_name
        else ("This User has no First Name")
    )
    last_name = (
        last_name.replace("\u2060", "") if last_name else ("This User has no Last Name")
    )
    username = "******".format(username) if username else ("This User has no Username")
    user_bio = "This User has no About" if not user_bio else user_bio
    caption = "<b>USER INFO from DARK COBRA's database :</b>\n\n"
    caption += f"👤First Name: {first_name} {last_name}\n"
    caption += f"🤵Username: {username}\n"
    caption += f"🔖ID: <code>{user_id}</code>\n"
    caption += f"🌏Data Centre ID: {dc_id}\n"
    caption += f"🖼Number of Profile Pics: {replied_user_profile_photos_count}\n"
    caption += f"🤖Is Bot: {is_bot}\n"
    caption += f"🔏Is Restricted: {restricted}\n"
    caption += f"🌐Is Verified by Telegram: {verified}\n\n"
    caption += f"✍️Bio: \n<code>{user_bio}</code>\n\n"
    caption += f"👥Common Chats with this user: {common_chat}\n"
    caption += f"🔗Permanent Link To Profile: "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 3
0
async def _(event):
    if event.fwd_from:
        return
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        return await edit_or_reply(event, f"`{str(error_i_a)}`")
    user_id = replied_user.user.id
    # some people have weird HTML in their names
    first_name = html.escape(replied_user.user.first_name)
    # https://stackoverflow.com/a/5072031/4723940
    # some Deleted Accounts do not have first_name
    if first_name is not None:
        # some weird people (like me) have more than 4096 characters in their
        # names
        first_name = first_name.replace("\u2060", "")
    # inspired by https://telegram.dog/afsaI181
    common_chats = replied_user.common_chats_count
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Couldn't fetch DC ID!"
    try:
        casurl = "https://api.cas.chat/check?user_id={}".format(user_id)
        data = get(casurl).json()
    except Exception as e:
        LOGS.info(e)
        data = None
    if data:
        if data["ok"]:
            cas = "**Antispam(CAS) Banned :** `True`"
        else:
            cas = "**Antispam(CAS) Banned :** `False`"
    else:
        cas = "**Antispam(CAS) Banned :** `Couldn't Fetch`"
    caption = """**Info of [{}](tg://user?id={}):
   -🔖ID : **`{}`
   **-**👥**Groups in Common : **`{}`
   **-**🌏**Data Centre Number : **`{}`
   **-**🔏**Restricted by telegram : **`{}`
   **-**🦅{}
   **-**👮‍♂️{}
""".format(
        first_name,
        user_id,
        user_id,
        common_chats,
        dc_id,
        replied_user.user.restricted,
        sw,
        cas,
    )
    await event.edit(caption)
Ejemplo n.º 4
0
async def fetch_info(replied_user, event):
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = LANG['NO_PROFILE_PHOTO']
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError as e:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = LANG['NO_DC_ID']
        location = str(e)
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = first_name.replace(
        "\u2060", "") if first_name else (LANG['NO_FIRST_NAME'])
    last_name = last_name.replace("\u2060",
                                  "") if last_name else (LANG['NO_LAST_NAME'])
    username = "******".format(username) if username else (LANG['NO_USERNAME'])
    user_bio = LANG['NO_BIO'] if not user_bio else user_bio

    caption = f"<b>{LANG['USER_INFO']}:</b>\n\n"
    caption += f"{LANG['NAME']}: {first_name}\n"
    caption += f"{LANG['LASTNAME']}: {last_name}\n"
    caption += f"{LANG['NICKNAME']}: {username}\n"
    caption += f"{LANG['DC_ID']}: {dc_id}\n"
    caption += f"{LANG['PROFILE_PHOTO_COUNT']}: {replied_user_profile_photos_count}\n"
    caption += f"{LANG['IS_BOT']}: {is_bot}\n"
    caption += f"{LANG['IS_RESTRICTED']}: {restricted}\n"
    caption += f"{LANG['IS_VERIFIED']}: {verified}\n"
    caption += f"ID: <code>{user_id}</code>\n\n"
    caption += f"{LANG['BIO']}: \n<code>{user_bio}</code>\n\n"
    caption += f"{LANG['COMMON_CHAT']}: {common_chat}\n"
    caption += f"{LANG['LINK']}: "
    caption += f"<a href=\"tg://user?id={user_id}\">{first_name}</a>"

    return photo, caption
Ejemplo n.º 5
0
async def fetch_info(replied_user, event):
    """ Dapatkan detail dari objek Pengguna. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "Orang tersebut membutuhkan bantuan untuk mengunggah gambar profil."
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "Tidak dapat mengambil DC ID!"
        str(e)
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = first_name.replace(
        "\u2060", "") if first_name else ("Pengguna ini tidak memiliki Nama")
    username = "******".format(username) if username else (
        "Pengguna ini tidak memiliki Nama Pengguna")
    user_bio = "This User has no About" if not user_bio else user_bio

    caption = "<b>BERIKUT YANG SAYA DAPATKAN DARI EMAK:</b>\n\n"
    caption += f"Nama: {fullname}\n"
    caption += f"Username: {username}\n"
    caption += f"DC ID: {dc_id}\n"
    caption += f"Jumlah Foto Profil: {replied_user_profile_photos_count}\n"
    caption += f"Bot: {is_bot}\n"
    caption += f"Terbatas: {restricted}\n"
    caption += f"Akun Terverifikasi: {verified}\n"
    caption += f"ID: <code>{user_id}</code>\n\n"
    caption += f"Bio: \n<code>{user_bio}</code>\n\n"
    caption += f"Grup Bersama: {common_chat}\n"
    caption += f"Tautan Permanen Ke Profil: "
    caption += f"<a href=\"tg://user?id={user_id}\">{first_name}</a>"

    return photo, caption
Ejemplo n.º 6
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "User haven't set profile pic"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Couldn't fetch DC ID!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("Fɪʀsᴛ Nᴀᴍᴇ Nᴏᴛ Fᴏᴜɴᴅ"))
    last_name = (last_name.replace("\u2060", "") if last_name else
                 ("Lᴀsᴛ Nᴀᴍᴇ Nᴏᴛ Fᴏᴜɴᴅ"))
    username = "******".format(username) if username else ("Nᴏ Usᴇʀɴᴀᴍᴇ Fᴏᴜɴᴅ")
    user_bio = "Nᴏ Aʙᴏᴜᴛ/Bɪᴏ Fᴏᴜɴᴅ" if not user_bio else user_bio
    caption = "<b>Exᴛʀᴀᴄᴛᴇᴅ Usᴇʀ Iɴғᴏ Bʏ UʟᴛʀᴀX</b>\n\n"
    caption += f"<b>┏━━━━━━━━━━━━━━━━━━━━━</b>\n"
    caption += f"<b>┣ Fɪʀsᴛ Nᴀᴍᴇ</b>: <code>{first_name}</code>\n"
    caption += f"<b>┣ Sᴇᴄᴏɴᴅ Nᴀᴍᴇ</b>: <code>{last_name}</code>\n"
    caption += f"<b>┣ Usᴇʀɴᴀᴍᴇ</b>: <i>{username}</i>\n"
    caption += f"<b>┣ Usᴇʀ Iᴅ</b>: <code>{user_id}</code>\n"
    caption += f"<b>┣ Dᴄ Iᴅ</b>: <code>{dc_id}</code>\n"
    caption += f"<b>┣ Nᴏ Oғ PғP</b>: <code>{replied_user_profile_photos_count}</code>\n"
    caption += f"<b>┣ Bᴏᴛ</b>: <code>{is_bot}</code>\n"
    caption += f"<b>┣ Rᴇsᴛʀɪᴄᴛᴇᴅ</b>: <code>{restricted}</code>\n"
    caption += f"<b>┣ Vᴇʀɪғɪᴇᴅ</b>: <code>{verified}</code>\n"
    caption += f"<b>┣ Bɪᴏ</b>: <code>{user_bio}</code>\n"
    caption += f"<b>┣ Gʀᴏᴜᴘs Iɴ Cᴏᴍᴍᴏɴ</b>: <code>{common_chat}</code>\n"
    caption += f"<b>┣ Lɪɴᴋ Tᴏ Pʀᴏғɪʟᴇ</b>: <i><a href='tg://user?id={user_id}'>Perma Link 🚪</a></i>\n"
    caption += f"<b>┗━━━━━━━━━━━━━━━━━━━━━</b>"
    return photo, caption
Ejemplo n.º 7
0
async def fetch_info(replied_user, event):
    """ Obtenga detalles del objeto Usuario. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "El usuario no ha establecido la foto de perfil"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "¡No se pudo obtener el ID de DC!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("Este usuario no tiene nombre"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else (
        "This User has no Username")
    user_bio = "Este usuario no tiene Descripción" if not user_bio else user_bio
    caption = "<b><i>INFORMACIÓN DEL USUARIO de la base de datos de Durov :</i></b>\n\n"
    caption += f"<b>👤 Primer nombre:</b> {first_name} {last_name}\n"
    caption += f"<b>🤵 Nombre de usuario:</b> {username}\n"
    caption += f"<b>🔖 ID:</b> <code>{user_id}</code>\n"
    caption += f"<b>🌏 ID del centro de datos:</b> {dc_id}\n"
    caption += (
        f"<b>🖼 Número de fotos de perfil:</b> {replied_user_profile_photos_count}\n"
    )
    caption += f"<b>🤖 Es un bot:</b> {is_bot}\n"
    caption += f"<b>🔏 Está restringido:</b> {restricted}\n"
    caption += f"<b>🌐 Está verificado por Telegram:</b> {verified}\n\n"
    caption += f"<b>✍️ Bio:</b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>👥 Grupos en común con este usuario:</b> {common_chat}\n"
    caption += f"<b>🔗 Link permanente a su perfil:</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 8
0
    def download(self, input_location):
        part_size = 64 * 1024

        dc_id, input_location = utils.get_input_location(input_location)
        exported = dc_id and self.client.session.dc_id != dc_id
        if exported:
            try:
                sender = TelegramFileManager.wait(
                    TelegramBaseClient._borrow_exported_sender(dc_id))
            except errors.DcIdInvalidError:
                config = TelegramFileManager.wait(
                    self(functions.help.GetConfigRequest()))
                for option in config.dc_options:
                    if option.ip_address == self.client.session.server_address:
                        self.client.session.set_dc(option.id,
                                                   option.ip_address,
                                                   option.port)
                        self.client.session.save()
                        break

                sender = self.client._sender
                exported = False
        else:
            sender = self.client._sender

        try:
            offset = 0
            while True:
                try:
                    result = TelegramFileManager.wait(
                        sender.send(
                            functions.upload.GetFileRequest(
                                input_location, offset, part_size)))
                    if isinstance(result, types.upload.FileCdnRedirect):
                        raise NotImplementedError
                except errors.FileMigrateError as e:
                    sender = TelegramFileManager.wait(
                        TelegramBaseClient._borrow_exported_sender(e.new_dc))
                    exported = True
                    continue

                offset += part_size
                if not result.bytes:
                    break

                yield result.bytes
        finally:
            if exported:
                TelegramFileManager.wait(self._return_exported_sender(sender))
            elif sender != self.client._sender:
                sender.disconnect()
Ejemplo n.º 9
0
async def fetch_info(replied_user, event):
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "Person needs help with uploading profile picture."
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError as e:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "Unknown"
        location = str(e)
    common_chat = str(replied_user.common_chats_count)
    if user_id == OWNER_ID:
        common_chat = "really, mate?"
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    first_name = first_name.replace("\u2060", "") if first_name else ("(N/A)")
    last_name = last_name.replace("\u2060", "") if last_name else ("(N/A)")
    username = "******".format(username) if username else ("(N/A)")
    user_bio = "This User has no About" if not user_bio else user_bio
    caption = "<b>USER INFO:</b>\n\n"
    caption += f"First Name: {first_name}\n"
    caption += f"Last Name: {last_name}\n"
    caption += f"Username: {username}\n"
    if user_id in HOMIES:
        caption += f"\nThis is one of my homies, respect him!\n\n"
    elif user_id == GIRLFRIEND:
        caption += f"\nThis is my girlfriend, leave her alone or you will get in trouble!\n\n"
    caption += f"Data Centre ID: {dc_id}\n"
    caption += f"Number of Profile Pics: {replied_user_profile_photos_count}\n"
    caption += f"Permanent Link To Profile: "
    caption += f"<a href=\"tg://user?id={user_id}\">{first_name}</a>\n"
    caption += f"Is Bot: {is_bot}\n"
    caption += f"Is Restricted: {restricted}\n"
    caption += f"Is Verified by Telegram: {verified}\n"
    caption += f"ID: <code>{user_id}</code>\n\n"
    caption += f"Bio: \n<code>{user_bio}</code>\n\n"
    caption += f"Common chats: {common_chat}\n"
    return caption
Ejemplo n.º 10
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(
            user_id=replied_user.user.id, offset=42, max_id=0, limit=80
        )
    )
    replied_user_profile_photos_count = "User haven't set profile pic"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Couldn't fetch DC ID!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(
        user_id, TMP_DOWNLOAD_DIRECTORY + str(user_id) + ".jpg", download_big=True
    )
    first_name = (
        first_name.replace("\u2060", "")
        if first_name
        else ("This User has no First Name")
    )
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else ("This User has no Username")
    user_bio = "This User has no About" if not user_bio else user_bio
    caption = "<b><i>✰ 𝕌𝚜𝚎𝚛 𝕀𝚗𝚏𝚘 𝔽𝚛𝚘𝚖 𝔻𝚞𝚛𝚘𝚞'𝐬 𝔻𝚊𝚝𝚊𝕓𝚊𝚜𝚎 ✰ :</i></b>\n\n"
    caption += f"<b>👤 ƒιяѕт ηαмє:</b> {first_name} {last_name}\n"
    caption += f"<b>🤵 υѕєяηαмє:</b> {username}\n"
    caption += f"<b>🔖 ID:</b> <code>{user_id}</code>\n"
    caption += f"<b>🌏 ∂αƚα ¢ҽɳƚɾҽ ι∂:</b> {dc_id}\n"
    caption += f"<b>🖼 ηυмвєя σƒ ρяσƒιℓє ρι¢ѕ:</b> {replied_user_profile_photos_count}\n"
    caption += f"<b>🤖 ιѕ вσт:</b> {is_bot}\n"
    caption += f"<b>🔏 ιѕ яєѕтяι¢тє∂:</b> {restricted}\n"
    caption += f"<b>🌐 ιѕ νєяιƒιє∂ ву тєℓєgяαм:</b> {verified}\n\n"
    caption += f"<b>✍️ вισ:</b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>👥 ¢σммση ¢нαтѕ ωιтн тнιѕ υѕєя:</b> {common_chat}\n"
    caption += f"<b>🔗 ρєямαηєηт ℓιηк тσ ρяσƒιℓє:</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 11
0
async def fetch_info(ruser, event):
    ruser_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=ruser.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    ruser_profile_photos_count = "Person needs help with uploading profile picture."
    try:
        ruser_profile_photos_count = ruser_profile_photos.count
    except AttributeError as e:
        pass
    user_id = ruser.user.id
    first_name = ruser.user.first_name
    last_name = ruser.user.last_name
    try:
        dc_id, location = get_input_location(ruser.profile_photo)
    except Exception as e:
        dc_id = "Couldn't fetch DC ID!"
        location = str(e)
    common_chat = ruser.common_chats_count
    username = ruser.user.username
    user_bio = ruser.about
    is_bot = ruser.user.bot
    restricted = ruser.user.restricted
    verified = ruser.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = first_name.replace(
        "\u2060", "") if first_name else ("This User has no First Name")
    last_name = last_name.replace(
        "\u2060", "") if last_name else ("This User has no Last Name")
    username = "******".format(username) if username else (
        "This User has no Username")
    user_bio = "This User has no About" if not user_bio else user_bio
    caption = "<b>USER INFO:</b>\n\n"
    caption += f"First Name: {first_name}\n"
    caption += f"Last Name: {last_name}\n"
    caption += f"Username: {username}\n"
    caption += f"Data Centre ID: {dc_id}\n"
    caption += f"Number of Profile Pics: {ruser_profile_photos_count}\n"
    caption += f"Is Bot: {is_bot}\n"
    caption += f"Is Restricted: {restricted}\n"
    caption += f"Is Verified by Telegram: {verified}\n"
    caption += f"ID: <code>{user_id}</code>\n\n"
    caption += f"Bio: \n<code>{user_bio}</code>\n\n"
    caption += f"Common Chats with this user: {common_chat}\n"
    caption += f"<a href=\"tg://user?id={user_id}\">{first_name}</a>"
    return photo, caption
Ejemplo n.º 12
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "Pengguna belum menyetel foto profil"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Couldn't fetch DC ID!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("Pengguna ini tidak memiliki Nama Depan"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else (
        "This User has no Username")
    user_bio = "This User has no About" if not user_bio else user_bio
    caption = "<b><i>Data pengguna :</i></b>\n\n"
    caption += f"<b>👤 Nama depan:</b> {first_name} {last_name}\n"
    caption += f"<b>🤵 Nama pengguna:</b> {username}\n"
    caption += f"<b>🔖 ID:</b> <code>{user_id}</code>\n"
    caption += f"<b>🌏 Pusat Data ID:</b> {dc_id}\n"
    caption += f"<b>🖼 Jumlah Foto Profil:</b> {replied_user_profile_photos_count}\n"
    caption += f"<b>🤖 Apakah Bot:</b> {is_bot}\n"
    caption += f"<b>🔏 Apakah Dibatasi:</b> {restricted}\n"
    caption += f"<b>🌐 Diverifikasi oleh Telegram:</b> {verified}\n\n"
    caption += f"<b>✍️ Bio:</b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>👥 Obrolan Umum dengan pengguna ini:</b> {common_chat}\n"
    caption += f"<b>🔗 Tautan Permanen Ke Profil:</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 13
0
async def fetch_info(replied_user, event):
    """ Obtenha detalhes do objeto Usuário. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "O usuário não tem foto de perfil"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Não foi possível buscar o DC ID!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("Esse usuário não tem nome"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else (
        "Este usuário não tem nome de usuário")
    user_bio = "Este usuário não tem bio" if not user_bio else user_bio
    caption = "<b><i>Informações do Usuário:</i></b>\n\n"
    caption += f"<b>👤 Nome:</b> {first_name} {last_name}\n"
    caption += f"<b>🤵 Nome de usuário:</b> {username}\n"
    caption += f"<b>🔖 ID:</b> <code>{user_id}</code>\n"
    caption += f"<b>🌏 ID Data Center:</b> {dc_id}\n"
    caption += f"<b>🖼 Fotos Perfil:</b> {replied_user_profile_photos_count}\n"
    caption += f"<b>🤖 Bot:</b> {is_bot}\n"
    caption += f"<b>🔏 Restrito:</b> {restricted}\n"
    caption += f"<b>🌐 Verificado:</b> {verified}\n\n"
    caption += f"<b>✍️ Bio:</b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>👥 Bate-papos comuns com este usuário:</b> {common_chat}\n"
    caption += f"<b>🔗 Link permanente para o perfil:</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 14
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "User haven't set profile pic"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Couldn't fetch DC ID!"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("This User has no First Name"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else (
        "This User has no Username")
    user_bio = "This User has no About" if not user_bio else user_bio
    caption = "<b><i>USER INFO from Durov's Database :</i></b>\n\n"
    caption += f"<b>Nama Depan :</b> {first_name} {last_name}\n"
    caption += f"<b>Username   :</b> {username}\n"
    caption += f"<b>ID         :</b> <code>{user_id}</code>\n"
    caption += f"<b>Data       :</b> {dc_id}\n"
    caption += f"<b>Amount PP  :</b> {replied_user_profile_photos_count}\n"
    caption += f"<b>Is Bot     :</b> {is_bot}\n"
    caption += f"<b>Restricted :</b> {restricted}\n"
    caption += f"<b>Verified   :</b> {verified}\n\n"
    caption += f"<b>Bio:</b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>Common Chats:</b> {common_chat}\n"
    caption += f"<b>Link Profile:</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 15
0
    def download(self, file: TypeLocation, file_size: int, offset: int, limit: int
                 ) -> AsyncGenerator[bytes, None]:
        dc_id, location = utils.get_input_location(file)
        part_size = 512 * 1024
        first_part_cut = offset % part_size
        first_part = math.floor(offset / part_size)
        last_part_cut = part_size - (limit % part_size)
        last_part = math.ceil(limit / part_size)
        part_count = math.ceil(file_size / part_size)
        self.log.debug(f"Starting parallel download: chunks {first_part}-{last_part}"
                       f" of {part_count} {location!s}")
        request = GetFileRequest(location, offset=first_part * part_size, limit=part_size)

        return self._int_download(request, first_part, last_part, part_count, part_size, dc_id,
                                  first_part_cut, last_part_cut)
Ejemplo n.º 16
0
async def _(event):
    if event.fwd_from:
        return
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        await event.edit(str(error_i_a))
        return False
    # logger.info(replied_user.stringify())
    user_id = replied_user.user.id
    # some people have weird HTML in their names
    first_name = html.escape(replied_user.user.first_name)
    # https://stackoverflow.com/a/5072031/4723940
    # some Deleted Accounts do not have first_name
    if first_name is not None:
        # some weird people (like me) have more than 4096 characters in their names
        first_name = first_name.replace("\u2060", "")
    # inspired by https://telegram.dog/afsaI181
    user_bio = replied_user.about
    if user_bio is not None:
        user_bio = html.escape(replied_user.about)
    common_chats = replied_user.common_chats_count
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "Need a Profile Picture to check **this**"
        location = str(e)
    caption = """ID: <code>{}</code>
Name: <a href='tg://user?id={}'>{}</a>
Bio: {}
DC ID: {}
Restricted: {}
Verified: {}
Bot: {}
Groups in Common: {}
""".format(user_id, user_id, first_name, user_bio, dc_id,
           replied_user.user.restricted, replied_user.user.verified,
           replied_user.user.bot, common_chats)
    message_id_to_reply = event.message.reply_to_msg_id
    if not message_id_to_reply:
        message_id_to_reply = event.message.id
    await borg.send_message(event.chat_id,
                            caption,
                            reply_to=message_id_to_reply,
                            parse_mode="HTML",
                            file=replied_user.profile_photo,
                            force_document=False,
                            silent=True)
    await event.delete()
Ejemplo n.º 17
0
async def parallel_transfer_to_matrix(
    client: MautrixTelegramClient,
    intent: IntentAPI,
    loc_id: str,
    location: TypeLocation,
    filename: str,
    encrypt: bool,
    parallel_id: int,
) -> DBTelegramFile:
    size = location.size
    mime_type = location.mime_type
    dc_id, location = utils.get_input_location(location)
    # We lock the transfers because telegram has connection count limits
    async with parallel_transfer_locks[parallel_id]:
        downloader = ParallelTransferrer(client, dc_id)
        data = downloader.download(location, size)
        decryption_info = None
        up_mime_type = mime_type
        if encrypt and async_encrypt_attachment:

            async def encrypted(stream):
                nonlocal decryption_info
                async for chunk in async_encrypt_attachment(stream):
                    if isinstance(chunk, EncryptedFile):
                        decryption_info = chunk
                    else:
                        yield chunk

            data = encrypted(data)
            up_mime_type = "application/octet-stream"
        content_uri = await intent.upload_media(
            data,
            mime_type=up_mime_type,
            filename=filename,
            size=size if not encrypt else None)
        if decryption_info:
            decryption_info.url = content_uri
    return DBTelegramFile(
        id=loc_id,
        mxc=content_uri,
        mime_type=mime_type,
        was_converted=False,
        timestamp=int(time.time()),
        size=size,
        width=None,
        height=None,
        decryption_info=decryption_info,
    )
Ejemplo n.º 18
0
async def download_file(client: TelegramClient,
                        location: TypeLocation,
                        out: BinaryIO,
                        progress_callback: callable = None) -> BinaryIO:
    size = location.size
    dc_id, location = utils.get_input_location(location)
    downloader = ParallelTransferrer(client, dc_id)
    downloaded = downloader.download(location, size)
    async for x in downloaded:
        out.write(x)
        if progress_callback:
            r = progress_callback(out.tell(), size)
            if inspect.isawaitable(r):
                await r

    return out
Ejemplo n.º 19
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(
            user_id=replied_user.user.id, offset=42, max_id=0, limit=80
        )
    )
    replied_user_profile_photos_count = "لاتوجد صوره بروفايل"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        pass
    replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    replied_user.user.bot
    replied_user.user.restricted
    replied_user.user.verified
    photo = await event.client.download_profile_photo(
        user_id, TMP_DOWNLOAD_DIRECTORY + str(user_id) + ".jpg", download_big=True
    )
    first_name = (
        first_name.replace("\u2060", "")
        if first_name
        else ("هذا المستخدم ليس له اسم أول")
    )
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else ("لايوجد معرف")
    user_bio = "لاتوجد نبذه" if not user_bio else user_bio
    caption = "<b><i> 𓆩 𝙎𝙊𝙐𝙍𝘾𝙀 𝙏𝙀𝙇𝙀𝙏𝙃𝙊𝙉 - 𝘿𝙀𝙁𝙍𝘼𝙓-𝙄𝙌 𓆪 </i></b>\n"
    caption += f"<b> 𖡰 🇮🇶 | 𝗇𝖺𝗆𝖾 ↬</b> `{first_name} {last_name}\n"
    caption += f"<b> 𖡰 🇮🇶 | 𝗎𝗌𝖾𝗋 𝗇𝖺𝗆𝖾 ↬</b> {username}\n"
    caption += f"<b> 𖡰 🇮🇶 | 𝗂𝖽 ↬</b> <code>{user_id}</code>\n"
    caption += f"<b> 𖡰 🇮🇶 | 𝗇𝗎𝗆𝖻𝖾𝗋 𝗈𝖿 𝗉𝗁𝗈𝗍𝗈 ↬</b> {replied_user_profile_photos_count}\n"
    caption += f"<b> 𖡰 🇮🇶 | 𝖻𝗂𝗈 ↬ </b>{user_bio}\n"
    caption += f"<b> 𖡰 🇮🇶 | 𝗅𝗂𝗇𝗄 𝖺𝖼𝖼𝗈𝗎𝗇𝗍 ↬</b> \n"
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a> \n'
    caption += f"<b> 𓆩 𝗍𝖾𝗅𝖾𝗍𝗁𝗈𝗇-𝖽𝖾𝖿𝗋𝖺x-𝗂𝗊 </b> - @DEFRAXIQ 𓆪 "
    return photo, caption
Ejemplo n.º 20
0
async def fetch_info(replied_user, event):
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "لاتوجد صوره بروفايل"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        pass
    replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    replied_user.user.bot
    replied_user.user.restricted
    replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("هذا المستخدم ليس له اسم أول"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else ("لايوجد معرف")
    user_bio = "لاتوجد نبذه" if not user_bio else user_bio
    caption = "<b><i> 𓆩 𝑺𝑶𝑼𝑹𝑪𝑬 𝙎𝘼𝘿𝙏𝙃𝙊𝙉 - 𝑷𝑹𝑶 𝑫𝑨𝑻𝑨 𓆪 </i></b>\n"
    caption += f"<b> 𓍹ⵧⵧⵧⵧⵧⵧⵧⵧⵧ𝕊𝔸𝔻𝕋ℍ𝕆ℕⵧⵧⵧⵧⵧⵧⵧⵧⵧ𓍻 </b>\n"
    caption += f"<b> • 🖤 | 𝑭𝑰𝑹𝑺𝑻 𝑵𝑨𝑴𝑬 𓆪</b> {first_name} {last_name}\n"
    caption += f"<b> • 🖤 | 𝑼𝑺𝑹 𓆪</b> {username}\n"
    caption += f"<b> • 🖤 | 𝑰𝑫 𓆪</b> <code>{user_id}</code>\n"
    caption += f"<b> • 🖤 | 𝑵𝑼𝑴𝑩𝑹 𝑶𝑭 𝑷𝑹𝑶 𝑷𝑰𝑪 𓆪</b> {replied_user_profile_photos_count}\n"
    caption += f"<b> • 🖤 | 𝑩𝑰𝑶 ↬ </b> \n {user_bio} \n"
    caption += f"<b> • 🖤 | 𝑴𝒀 𝑷𝑹𝑶 𝑳𝑰𝑵𝑲 𓆪</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    caption += f"<b> 𓍹ⵧⵧⵧⵧⵧⵧⵧⵧⵧ𝕊𝔸𝔻𝕋ℍ𝕆ℕⵧⵧⵧⵧⵧⵧⵧⵧⵧ𓍻 </b>\n"
    caption += f"<b> 𓆩 𝙎𝙊𝙐𝙍𝘾𝞝</b> 𝘿𝙀𝙑 - @sadthon 𓆪 "
    return photo, caption
Ejemplo n.º 21
0
async def fetch_info(replied_user, event):
    """Get details from the User object."""
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "لاتوجد صوره بروفايل"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception:
        pass
    replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    replied_user.user.bot
    replied_user.user.restricted
    replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("هذا المستخدم ليس له اسم أول"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else ("لايوجد معرف")
    user_bio = "لاتوجد نبذه" if not user_bio else user_bio
    caption = "<b><i>˹Yꪮꪶꪖꪀᦔ˼༒࿅ ↫</i></b>\n\n"
    caption += f"<b>☆ F𝑖𝑟𝑠𝑡 N𝑎𝑚𝑒:</b> {first_name} {last_name}\n"
    caption += f"<b>☆ U𝑠𝑒𝑟𝑛𝑎𝑚𝑒:</b> {username}\n"
    caption += f"<b>☆ ID:</b> <code>{user_id}</code>\n"
    caption += (
        f"<b>☆ N𝑢𝑚𝑏𝑒𝑟 𝑜f P𝑟𝑜f𝑖𝑙𝑒 P𝑖𝑐𝑠 :</b> {replied_user_profile_photos_count}\n"
    )
    caption += f"<b>☆ B𝑖𝑜 ↬ </b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>☆ P𝑒𝑟𝑚𝑎𝑛𝑒𝑛𝑡 L𝑖𝑛𝑘 T𝑜 P𝑟𝑜f𝑖𝑙𝑒 :</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 22
0
async def fetch_info(replied_user, event):
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "L'utente non ha una foto profilo"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        dc_id = "Non posso ottenere il DC"
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("L'utente non ha il primo nome"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else (
        "Questo utente non ha un ursemane")
    user_bio = "Questo utente non ha la bio" if not user_bio else user_bio
    caption = "<b><i>Info di questo:</i></b>\n\n"
    caption += f"<b>Nome e cognome:</b> <code>{first_name} {last_name}</code>\n"
    caption += f"<b>Username:</b> <code>{username}</code>\n"
    caption += f"<b> ID:</b> <code>{user_id}</code>\n"
    caption += f"<b>DC id:</b> {dc_id}\n"
    caption += f"<b>Numero di foto profilo:</b> {replied_user_profile_photos_count}\n"
    caption += f"<b>Bio:</b> \n<code>{user_bio}</code>\n\n"
    caption += f"<b>Chat in comune:</b> {common_chat}\n"
    caption += f"<b>Perma link:</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    return photo, caption
Ejemplo n.º 23
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = (
        "Person needs help with uploading profile picture.")
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, _ = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "Couldn't fetch DC ID!"
        str(e)
    common_chat = replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    is_bot = replied_user.user.bot
    restricted = replied_user.user.restricted
    verified = replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TEMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("This User has no First Name"))
    last_name = (last_name.replace("\u2060", "") if last_name else
                 ("This User has no Last Name"))
    username = "******".format(username) if username else (
        "This User has no Username")
    user_bio = "This User has no About" if not user_bio else user_bio

    caption = "<b>USER INFO:</b>\n\n"
    caption += f"First Name: {first_name}\n"
    caption += f"Last Name: {last_name}\n"
    caption += f"Username: {username}\n"

    return photo, caption
Ejemplo n.º 24
0
async def fetch_info(replied_user, event):
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "لاتوجد صوره بروفايل"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        pass
    replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    replied_user.user.bot
    replied_user.user.restricted
    replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("هذا المستخدم ليس له اسم أول"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else ("لايوجد معرف")
    user_bio = "لاتوجد نبذه" if not user_bio else user_bio
    caption = "<b><i> 𓆩 المطور حسين كريم  𓆪 </i></b>\n"
    caption += f"<b> 𓍹ⵧⵧⵧⵧⵧⵧⵧⵧⵧ𝐢𝐜𝐬𝐬ⵧⵧⵧⵧⵧⵧⵧⵧⵧ𓍻 </b>\n"
    caption += f"<b> • 🖤 | اسمك 𓆪</b> {first_name} {last_name}\n"
    caption += f"<b> • 🖤 | معرفك 𓆪</b> {username}\n"
    caption += f"<b> • 🖤 | ايديك 𓆪</b> <code>{user_id}</code>\n"
    caption += f"<b> • 🖤 | عدد اصورك 𓆪</b> {replied_user_profile_photos_count}\n"
    caption += f"<b> • 🖤 | نبذه ↬ </b> \n {user_bio} \n"
    caption += f"<b> • 🖤 | المستخدم 𓆪</b> "
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a>'
    caption += f"<b> 𓍹ⵧⵧⵧⵧⵧⵧⵧⵧⵧ𖠕 بروفايلك 𖠕ⵧⵧⵧⵧⵧⵧⵧⵧⵧ𓍻 </b>\n"
    caption += f"<b> 𓆩 المطور</b>𖠕- @IXKKl 𓆪 "
    return photo, caption
Ejemplo n.º 25
0
async def download_file(client: TelegramClient,
                        location: TypeLocation,
                        out: BinaryIO,
                        progress_callback: Callable[[int, int], None] = None
                        ) -> BinaryIO:
    size = location.size
    dc_id, location = utils.get_input_location(location)
    # We lock the transfers because telegram has connection count limits
    downloader = ParallelTransferrer(client, dc_id)
    downloaded = downloader.download(location, size)
    async for x in downloaded:
        out.write(x)
        if progress_callback:
            r = progress_callback(out.tell(), size)
            if inspect.isawaitable(r):
                await r

    return out
Ejemplo n.º 26
0
async def fetch_info(replied_user, event):
    """ Get details from the User object. """
    replied_user_profile_photos = await event.client(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "لاتوجد صوره بروفايل"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = replied_user.user.first_name
    last_name = replied_user.user.last_name
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except:
        pass
    replied_user.common_chats_count
    username = replied_user.user.username
    user_bio = replied_user.about
    replied_user.user.bot
    replied_user.user.restricted
    replied_user.user.verified
    photo = await event.client.download_profile_photo(user_id,
                                                      TMP_DOWNLOAD_DIRECTORY +
                                                      str(user_id) + ".jpg",
                                                      download_big=True)
    first_name = (first_name.replace("\u2060", "") if first_name else
                  ("هذا المستخدم ليس له اسم أول"))
    last_name = last_name.replace("\u2060", "") if last_name else (" ")
    username = "******".format(username) if username else ("لايوجد معرف")
    user_bio = "لاتوجد نبذه" if not user_bio else user_bio
    caption = "<b><i> 𓆩LEO SOURCE 𓆪 </i></b>\n"
    caption += f"<b> • 🇲🇦 | الأسم ↬</b> {first_name} {last_name}\n"
    caption += f"<b> • 🇲🇦 | الـمعرف ↬</b> {username}\n"
    caption += f"<b> • 🇲🇦 | الايدي ↬</b> <code>{user_id}</code>\n"
    caption += f"<b> • 🇲🇦 | عـدد الصور ↬</b> {replied_user_profile_photos_count}\n"
    caption += f"<b> • 🇲🇦 | النبـذة ↬ </b> {user_bio} \n"
    caption += f"<b> • 🇲🇦 | حـسابه ↬</b> \n"
    caption += f'<a href="tg://user?id={user_id}">{first_name}</a> \n'
    caption += f"<b> 𓆩 LEO SOURCE</b> - @QHR_1 𓆪 "
    return photo, caption
Ejemplo n.º 27
0
async def parallel_transfer_to_matrix(client: MautrixTelegramClient,
                                      intent: IntentAPI, loc_id: str,
                                      location: TypeLocation, filename: str,
                                      parallel_id: int) -> DBTelegramFile:
    size = location.size
    mime_type = location.mime_type
    dc_id, location = utils.get_input_location(location)
    # We lock the transfers because telegram has connection count limits
    async with parallel_transfer_locks[parallel_id]:
        downloader = ParallelTransferrer(client, dc_id)
        content_uri = await intent.upload_media(downloader.download(
            location, size),
                                                mime_type=mime_type,
                                                filename=filename,
                                                size=size)
    return DBTelegramFile(id=loc_id,
                          mxc=content_uri,
                          mime_type=mime_type,
                          was_converted=False,
                          timestamp=int(time.time()),
                          size=size,
                          width=None,
                          height=None)
Ejemplo n.º 28
0
async def _(event):
    if event.fwd_from:
        return
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        await event.edit(str(error_i_a))
        return False
    replied_user_profile_photos = await borg(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "NaN"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    # some people have weird HTML in their names
    first_name = html.escape(replied_user.user.first_name)
    # https://stackoverflow.com/a/5072031/4723940
    # some Deleted Accounts do not have first_name
    if first_name is not None:
        # some weird people (like me) have more than 4096 characters in their
        # names
        first_name = first_name.replace("\u2060", "")
        last_name = replied_user.user.last_name
    # last_name is not Manadatory in @Telegram
    if last_name is not None:
        last_name = html.escape(last_name)
        last_name = last_name.replace("\u2060", "")
    # inspired by https://telegram.dog/afsaI181
    user_bio = replied_user.about
    if user_bio is not None:
        user_bio = html.escape(replied_user.about)
    common_chats = replied_user.common_chats_count
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "Need a Profile Picture to check **this**"
        str(e)
    caption = """Detailed Whois:

🔖ID: <code>{}</code>
👱First Name: <a href='tg://user?id={}'>{}</a>
❣️Last Name: {}
✍️Bio: {}
🗄️Data Centre Number: {}
🖼 Number of Profile Pics: {}
🔏Restricted: {}
✴️Verified: {}
🤖Bot: {}
👥Groups in Common: {}
""".format(user_id, user_id, first_name, last_name, user_bio, dc_id,
           replied_user_profile_photos_count, replied_user.user.restricted,
           replied_user.user.verified, replied_user.user.bot, common_chats)
    message_id_to_reply = event.message.reply_to_msg_id
    if not message_id_to_reply:
        message_id_to_reply = event.message.id
    await borg.send_message(event.chat_id,
                            caption,
                            reply_to=message_id_to_reply,
                            parse_mode="HTML",
                            file=replied_user.profile_photo,
                            force_document=False,
                            silent=True)
    await event.delete()
Ejemplo n.º 29
0
async def fetch_info(chat, event):
    # chat.chats is a list so we use get_entity() to avoid IndexError
    chat_obj_info = await event.client.get_entity(chat.full_chat.id)
    broadcast = (chat_obj_info.broadcast
                 if hasattr(chat_obj_info, "broadcast") else False)
    chat_type = "Channel" if broadcast else "Group"
    chat_title = chat_obj_info.title
    warn_emoji = "⚠️"
    try:
        msg_info = await event.client(
            GetHistoryRequest(
                peer=chat_obj_info.id,
                offset_id=0,
                offset_date=datetime(2010, 1, 1),
                add_offset=-1,
                limit=1,
                max_id=0,
                min_id=0,
                hash=0,
            ))
    except Exception as e:
        msg_info = None
        print("Exception:", e)
    # No chance for IndexError as it checks for msg_info.messages first
    first_msg_valid = (True if msg_info and msg_info.messages
                       and msg_info.messages[0].id == 1 else False)
    # Same for msg_info.users
    creator_valid = True if first_msg_valid and msg_info.users else False
    creator_id = msg_info.users[0].id if creator_valid else None
    creator_firstname = (msg_info.users[0].first_name if creator_valid
                         and msg_info.users[0].first_name is not None else
                         "Deleted Account")
    creator_username = (msg_info.users[0].username if creator_valid
                        and msg_info.users[0].username is not None else None)
    created = msg_info.messages[0].date if first_msg_valid else None
    former_title = (
        msg_info.messages[0].action.title if first_msg_valid and
        type(msg_info.messages[0].action) is MessageActionChannelMigrateFrom
        and msg_info.messages[0].action.title != chat_title else None)
    try:
        dc_id, location = get_input_location(chat.full_chat.chat_photo)
    except Exception as e:
        dc_id = "Unknown"
        str(e)

    # this is some spaghetti I need to change
    description = chat.full_chat.about
    members = (chat.full_chat.participants_count if hasattr(
        chat.full_chat, "participants_count") else
               chat_obj_info.participants_count)
    admins = (chat.full_chat.admins_count
              if hasattr(chat.full_chat, "admins_count") else None)
    banned_users = (chat.full_chat.kicked_count if hasattr(
        chat.full_chat, "kicked_count") else None)
    restrcited_users = (chat.full_chat.banned_count if hasattr(
        chat.full_chat, "banned_count") else None)
    members_online = (chat.full_chat.online_count if hasattr(
        chat.full_chat, "online_count") else 0)
    group_stickers = (chat.full_chat.stickerset.title
                      if hasattr(chat.full_chat, "stickerset")
                      and chat.full_chat.stickerset else None)
    messages_viewable = msg_info.count if msg_info else None
    messages_sent = (chat.full_chat.read_inbox_max_id if hasattr(
        chat.full_chat, "read_inbox_max_id") else None)
    messages_sent_alt = (chat.full_chat.read_outbox_max_id if hasattr(
        chat.full_chat, "read_outbox_max_id") else None)
    exp_count = chat.full_chat.pts if hasattr(chat.full_chat, "pts") else None
    username = chat_obj_info.username if hasattr(chat_obj_info,
                                                 "username") else None
    bots_list = chat.full_chat.bot_info  # this is a list
    bots = 0
    supergroup = ("<b>Yes</b>" if hasattr(chat_obj_info, "megagroup")
                  and chat_obj_info.megagroup else "No")
    slowmode = ("<b>Yes</b>" if hasattr(chat_obj_info, "slowmode_enabled")
                and chat_obj_info.slowmode_enabled else "No")
    slowmode_time = (chat.full_chat.slowmode_seconds
                     if hasattr(chat_obj_info, "slowmode_enabled")
                     and chat_obj_info.slowmode_enabled else None)
    restricted = ("<b>Yes</b>" if hasattr(chat_obj_info, "restricted")
                  and chat_obj_info.restricted else "No")
    verified = ("<b>Yes</b>" if hasattr(chat_obj_info, "verified")
                and chat_obj_info.verified else "No")
    username = "******".format(username) if username else None
    creator_username = "******".format(
        creator_username) if creator_username else None
    # end of spaghetti block

    if admins is None:
        # use this alternative way if chat.full_chat.admins_count is None, works even without being an admin
        try:
            participants_admins = await event.client(
                GetParticipantsRequest(
                    channel=chat.full_chat.id,
                    filter=ChannelParticipantsAdmins(),
                    offset=0,
                    limit=0,
                    hash=0,
                ))
            admins = participants_admins.count if participants_admins else None
        except Exception as e:
            print("Exception:", e)
    if bots_list:
        for bot in bots_list:
            bots += 1

    caption = "<b>CHAT INFO:</b>\n"
    caption += f"ID: <code>{chat_obj_info.id}</code>\n"
    if chat_title is not None:
        caption += f"{chat_type} name: {chat_title}\n"
    if former_title is not None:  # Meant is the very first title
        caption += f"Former name: {former_title}\n"
    if username is not None:
        caption += f"{chat_type} type: Public\n"
        caption += f"Link: {username}\n"
    else:
        caption += f"{chat_type} type: Private\n"
    if creator_username is not None:
        caption += f"Creator: {creator_username}\n"
    elif creator_valid:
        caption += (
            f'Creator: <a href="tg://user?id={creator_id}">{creator_firstname}</a>\n'
        )
    if created is not None:
        caption += f"Created: <code>{created.date().strftime('%b %d, %Y')} - {created.time()}</code>\n"
    else:
        caption += f"Created: <code>{chat_obj_info.date.date().strftime('%b %d, %Y')} - {chat_obj_info.date.time()}</code> {warn_emoji}\n"
    caption += f"Data Centre ID: {dc_id}\n"
    if exp_count is not None:
        chat_level = int((1 + sqrt(1 + 7 * exp_count / 14)) / 2)
        caption += f"{chat_type} level: <code>{chat_level}</code>\n"
    if messages_viewable is not None:
        caption += f"Viewable messages: <code>{messages_viewable}</code>\n"
    if messages_sent:
        caption += f"Messages sent: <code>{messages_sent}</code>\n"
    elif messages_sent_alt:
        caption += f"Messages sent: <code>{messages_sent_alt}</code> {warn_emoji}\n"
    if members is not None:
        caption += f"Members: <code>{members}</code>\n"
    if admins is not None:
        caption += f"Administrators: <code>{admins}</code>\n"
    if bots_list:
        caption += f"Bots: <code>{bots}</code>\n"
    if members_online:
        caption += f"Currently online: <code>{members_online}</code>\n"
    if restrcited_users is not None:
        caption += f"Restricted users: <code>{restrcited_users}</code>\n"
    if banned_users is not None:
        caption += f"Banned users: <code>{banned_users}</code>\n"
    if group_stickers is not None:
        caption += f'{chat_type} stickers: <a href="t.me/addstickers/{chat.full_chat.stickerset.short_name}">{group_stickers}</a>\n'
    caption += "\n"
    if not broadcast:
        caption += f"Slow mode: {slowmode}"
        if (hasattr(chat_obj_info, "slowmode_enabled")
                and chat_obj_info.slowmode_enabled):
            caption += f", <code>{slowmode_time}s</code>\n\n"
        else:
            caption += "\n\n"
    if not broadcast:
        caption += f"Supergroup: {supergroup}\n\n"
    if hasattr(chat_obj_info, "restricted"):
        caption += f"Restricted: {restricted}\n"
        if chat_obj_info.restricted:
            caption += f"> Platform: {chat_obj_info.restriction_reason[0].platform}\n"
            caption += f"> Reason: {chat_obj_info.restriction_reason[0].reason}\n"
            caption += f"> Text: {chat_obj_info.restriction_reason[0].text}\n\n"
        else:
            caption += "\n"
    if hasattr(chat_obj_info, "scam") and chat_obj_info.scam:
        caption += "Scam: <b>Yes</b>\n\n"
    if hasattr(chat_obj_info, "verified"):
        caption += f"Verified by Telegram: {verified}\n\n"
    if description:
        caption += f"Description: \n<code>{description}</code>\n"
    return caption
Ejemplo n.º 30
0
async def _(event):
    if event.fwd_from:
        return
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        await event.edit(str(error_i_a))
        return False
    replied_user_profile_photos = await borg(
        GetUserPhotosRequest(user_id=replied_user.user.id,
                             offset=42,
                             max_id=0,
                             limit=80))
    replied_user_profile_photos_count = "NaN"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
        pass
    user_id = replied_user.user.id
    first_name = html.escape(replied_user.user.first_name)
    if first_name is not None:
        first_name = first_name.replace("\u2060", "")
    last_name = replied_user.user.last_name
    last_name = (last_name.replace("\u2060", "") if last_name else
                 ("Last Name not found"))
    user_bio = replied_user.about
    if user_bio is not None:
        user_bio = html.escape(replied_user.about)
    common_chats = replied_user.common_chats_count
    try:
        dc_id, location = get_input_location(replied_user.profile_photo)
    except Exception as e:
        dc_id = "`Need a Profile Picture to check **this**`"
        str(e)
    caption = """<b>Extracted User info From Telegram<b>
    
<b>🆔️ User ID</b>: <code>{}</code>
<b>📎 Link To Profile</b>: <a href='tg://user?id={}'>Click Here🚪</a>
<b>🗣️ First Name</b>: <code>{}</code>
<b>🗣️ Second Name</b>: <code>{}</code>
<b>👨🏿‍💻 BIO</b>: {}
<b>🌐 DC ID</b>: {}
<b>📸 NO OF PSS</b> : {}
<b>🧐 RESTRICTED</b>: {}
<b>✅ VERIFIED</b>: {}
<b>🤖 BOT</b>: {}
<b>👥 Groups in Common</b>: {}

<b>⚡ <a href='https://t.me/W2H_Userbot'>From DataBase of W2HBOT</a> ⚡ </b>
""".format(
        user_id,
        user_id,
        first_name,
        last_name,
        user_bio,
        dc_id,
        replied_user_profile_photos_count,
        replied_user.user.restricted,
        replied_user.user.verified,
        replied_user.user.bot,
        common_chats,
    )
    message_id_to_reply = event.message.reply_to_msg_id
    if not message_id_to_reply:
        message_id_to_reply = event.message.id
    await borg.send_message(
        event.chat_id,
        caption,
        reply_to=message_id_to_reply,
        parse_mode="HTML",
        file=replied_user.profile_photo,
        force_document=False,
        silent=True,
    )
    await event.delete()