コード例 #1
0
async def clone(client, message):
    if message.reply_to_message:
        target = message.reply_to_message.from_user.id
    elif len(message.text.split()) >= 2 and message.text.split()[1].isdigit():
        await edrep(message, text="Select target user to clone their identity!")
    else:
        await edrep(message, text="Select target user to clone their identity!")
    if "origin" in message.text:
        my_self = await app.get_me()
        my_self = await client.send(functions.users.GetFullUser(id=await client.resolve_peer(my_self['id'])))

        # Backup my first name, last name, and bio
        backup_indentity(my_self['user']['first_name'], my_self['user']['last_name'], my_self['about'])
    q = await app.get_profile_photos(target)
    await client.download_media(q[0], file_name="nana/downloads/pp.png")
    await app.set_profile_photo("nana/downloads/pp.png")
    t = await app.get_users(target)
    t = await client.send(functions.users.GetFullUser(id=await client.resolve_peer(t['id'])))
    p_file = functions.account
    await client.send(
        p_file.UpdateProfile(first_name=t['user']['first_name'] if t['user']['first_name'] is not None else "",
                             last_name=t['user']['last_name'] if t['user']['last_name'] is not None else "",
                             about=t['about'] if t['about'] is not None else ""))
    await edrep(message, text="`New identity has changed!`")
    await sleep(5)
    await message.delete()
コード例 #2
0
ファイル: cloner.py プロジェクト: zeuslord224/Nana-Userbot
async def clone(client, message):
    if message.reply_to_message:
        target = message.reply_to_message.from_user.id
    elif len(message.text.split()) >= 2 and message.text.split()[1].isdigit():
        # TODO
        await message.edit("Select target user to clone their identity!")
    else:
        await message.edit("Select target user to clone their identity!")

    if "origin" in message.text:
        # Backup yours current identity
        my_self = await app.get_me()
        my_self = await client.send(
            functions.users.GetFullUser(
                id=await client.resolve_peer(my_self['id'])))

        # Backup my first name, last name, and bio
        backup_indentity(my_self['user']['first_name'],
                         my_self['user']['last_name'], my_self['about'])

    # Get target pp
    q = await app.get_profile_photos(target)

    # Download it
    await client.download_media(q[0], file_name="nana/downloads/pp.png")

    # Set new pp
    await app.set_profile_photo("nana/downloads/pp.png")

    # Get target profile
    t = await app.get_users(target)
    t = await client.send(
        functions.users.GetFullUser(id=await client.resolve_peer(t['id'])))

    # Set new name
    await client.send(
        functions.account.UpdateProfile(
            first_name=t['user']['first_name']
            if t['user']['first_name'] != None else "",
            last_name=t['user']['last_name']
            if t['user']['last_name'] != None else "",
            about=t['about'] if t['about'] != None else ""))

    # Kaboom! Done!
    await message.edit("Kaboom!\nNew identity has changed!")