コード例 #1
0
async def change_photo(tg_user):
    client = TelegramClient('anon', tg_user.api_id, tg_user.api_hash)

    try:
        await client.connect()
        channel_entity = await client.get_me(input_peer=True)

        if not await client.is_user_authorized():
            await client.send_code_request(tg_user.phone)
            await client.sign_in(tg_user.phone, tg_user.secret_tg_key)

        if await client.is_user_authorized():
            current_photo = await client.get_profile_photos(channel_entity)
            if current_photo:
                await client(DeletePhotosRequest(current_photo))

            await client.upload_file(file=settings.PICTURE_NAME)
            await client(
                UploadProfilePhotoRequest(await client.upload_file(
                    settings.PICTURE_NAME)))

        await client.disconnect()

    except Exception:
        await client.disconnect()
        logger.exception(msg='Exception!')
コード例 #2
0
 def _update_avatar(self, image_path):
     logger.info('Delete old photos')
     self.connection(
         DeletePhotosRequest(self.connection.get_profile_photos('me')))
     file = self.connection.upload_file(image_path)
     logger.info('Create new photo')
     self.connection(UploadProfilePhotoRequest(file))
コード例 #3
0
ファイル: profile.py プロジェクト: thewhiteharlot/PurpleBot
async def set_profilepic(propic):
    """For .profilepic command, change your profile picture in Telegram."""
    replymsg = await propic.get_reply_message()
    photo = None
    if replymsg.media:
        if isinstance(replymsg.media, MessageMediaPhoto):
            photo = await propic.client.download_media(message=replymsg.photo)
        elif "image" in replymsg.media.document.mime_type.split("/"):
            photo = await propic.client.download_file(replymsg.media.document)
        else:
            await propic.edit(INVALID_MEDIA)

    if photo:
        try:
            await propic.client(
                UploadProfilePhotoRequest(await
                                          propic.client.upload_file(photo)))
            os.remove(photo)
            await propic.edit(PP_CHANGED)
        except PhotoCropSizeSmallError:
            await propic.edit(PP_TOO_SMOL)
        except ImageProcessFailedError:
            await propic.edit(PP_ERROR)
        except PhotoExtInvalidError:
            await propic.edit(INVALID_MEDIA)
コード例 #4
0
async def _(event):
    if event.fwd_from:
        return
    reply_message = await event.get_reply_message()
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        await event.edit(str(error_i_a))
        return False
    user_id = replied_user.user.id
    profile_pic = await event.client.download_profile_photo(
        user_id, TEMP_DOWNLOAD_DIRECTORY)
    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
    if last_name is not None:
        last_name = html.escape(last_name)
        last_name = last_name.replace("\u2060", "")
    if last_name is None:
        last_name = ""
    user_bio = replied_user.about
    if user_bio is not None:
        user_bio = replied_user.about
    await event.edit("`Processing...`")
    await event.client(
        UpdateProfileRequest(first_name=first_name, last_name=last_name))
    await event.client(UpdateProfileRequest(about=user_bio))
    await event.client(
        UploadProfilePhotoRequest(await event.client.upload_file(profile_pic)))
    os.remove(profile_pic)
    await event.edit("Cloned Successfully")
    event.delete()
    event.client.send_message(event.chat_id,
                              "Cloned Successfully",
                              reply_to=reply_message)
コード例 #5
0
async def set_profilepic(propic):
    """ .profilepic komutu Telegram'daki profil resminizi yanıtladığınız resimle değişir. """
    replymsg = await propic.get_reply_message()
    photo = None
    if replymsg.media:
        if isinstance(replymsg.media, MessageMediaPhoto):
            photo = await propic.client.download_media(message=replymsg.photo)
        elif "image" in replymsg.media.document.mime_type.split('/'):
            photo = await propic.client.download_file(replymsg.media.document)
        else:
            await propic.edit(INVALID_MEDIA)

    if photo:
        try:
            await propic.client(
                UploadProfilePhotoRequest(await
                                          propic.client.upload_file(photo)))
            os.remove(photo)
            await propic.edit(PP_CHANGED)
        except PhotoCropSizeSmallError:
            await propic.edit(PP_TOO_SMOL)
        except ImageProcessFailedError:
            await propic.edit(PP_ERROR)
        except PhotoExtInvalidError:
            await propic.edit(INVALID_MEDIA)
コード例 #6
0
ファイル: clone.py プロジェクト: itexpert120/CyberDoge
async def updateProfile(userObj, reset=False):
    firstName = "Deleted Account" if userObj.user.first_name is None else userObj.user.first_name
    lastName = "" if userObj.user.last_name is None else userObj.user.last_name
    userAbout = userObj.about if userObj.about is not None else ""
    userAbout = "" if len(userAbout) > 70 else userAbout
    if reset:
        userPfps = await client.get_profile_photos('me')
        userPfp = userPfps[0]
        await client(
            DeletePhotosRequest(id=[
                InputPhoto(id=userPfp.id,
                           access_hash=userPfp.access_hash,
                           file_reference=userPfp.file_reference)
            ]))
    else:
        try:
            userPfp = userObj.profile_photo
            pfpImage = await client.download_media(userPfp)
            await client(
                UploadProfilePhotoRequest(await client.upload_file(pfpImage)))
        except:
            pass
    await client(
        UpdateProfileRequest(about=userAbout,
                             first_name=firstName,
                             last_name=lastName))
コード例 #7
0
async def autopic(e):
    search = e.pattern_match.group(1)
    if not search:
        return await eod(e, get_string("autopic_1"))
    clls = autopicsearch(search)
    if len(clls) == 0:
        return await eod(e, get_string("autopic_2").format(search))
    await eor(e, get_string("autopic_3").format(search))
    udB.set("AUTOPIC", "True")
    while True:
        for lie in clls:
            ge = udB.get("AUTOPIC")
            if not ge == "True":
                return
            au = "https://unsplash.com" + lie["href"]
            et = await ultroid_bot(getweb(au))
            try:
                kar = await ultroid_bot.download_media(et.webpage.photo)
            except AttributeError:
                ct = r.get(au).content
                bsc = bs(ct, "html.parser", from_encoding="utf-8")
                ft = bsc.find_all("img", "_2UpQX")
                li = ft[0]["src"]
                kar = "autopic.png"
                urllib.request.urlretrieve(li, kar)
            file = await ultroid_bot.upload_file(kar)
            await ultroid_bot(UploadProfilePhotoRequest(file))
            os.remove(kar)
            await asyncio.sleep(1111)
コード例 #8
0
async def pfp(context):
    """ Sets your profile picture. """
    reply = await context.get_reply_message()
    photo = None
    await context.edit("设置头像中 . . .")
    if reply.media:
        if isinstance(reply.media, MessageMediaPhoto):
            photo = await bot.download_media(message=reply.photo)
        elif "image" in reply.media.document.mime_type.split('/'):
            photo = await bot.download_file(reply.media.document)
        else:
            await context.edit("出错了呜呜呜 ~ 无法将此附件解析为图片。")

    if photo:
        try:
            await bot(UploadProfilePhotoRequest(
                await bot.upload_file(photo)
            ))
            remove(photo)
            await context.edit("头像修改成功啦 ~")
        except PhotoCropSizeSmallError:
            await context.edit("出错了呜呜呜 ~ 此图像尺寸小于最小要求。")
        except ImageProcessFailedError:
            await context.edit("出错了呜呜呜 ~ 服务器解释命令时发生错误。")
        except PhotoExtInvalidError:
            await context.edit("出错了呜呜呜 ~ 无法将此附件解析为图片。")
コード例 #9
0
ファイル: autopic.py プロジェクト: nryadav7412/Ultroid
async def autopic(e):
    search = e.pattern_match.group(1).strip()
    if udB.get_key("AUTOPIC") and not search:
        udB.del_key("AUTOPIC")
        return await e.eor(get_string("autopic_5"))
    if not search:
        return await e.eor(get_string("autopic_1"), time=5)
    e = await e.eor(get_string("com_1"))
    gi = googleimagesdownload()
    args = {
        "keywords": search,
        "limit": 50,
        "format": "jpg",
        "output_directory": "./resources/downloads/",
    }
    try:
        pth = await gi.download(args)
        ok = pth[0][search]
    except Exception as er:
        LOGS.exception(er)
        return await e.eor(str(er))
    if not ok:
        return await e.eor(get_string("autopic_2").format(search), time=5)
    await e.eor(get_string("autopic_3").format(search))
    udB.set_key("AUTOPIC", search)
    SLEEP_TIME = udB.get_key("SLEEP_TIME") or 1221
    while True:
        for lie in ok:
            if udB.get_key("AUTOPIC") != search:
                return
            file = await e.client.upload_file(lie)
            await e.client(UploadProfilePhotoRequest(file))
            await asyncio.sleep(SLEEP_TIME)
        shuffle(ok)
コード例 #10
0
ファイル: profile.py プロジェクト: alinebot/denvil-userbot2
async def profile_pic(ppic):
    if not ppic.text[0].isalpha() and ppic.text[0] not in ("/", "#", "@", "!"):
        message = await ppic.get_reply_message()
        photo = None
        if message.media:
            if isinstance(message.media, MessageMediaPhoto):
                photo = message.photo
                photo = await bot.download_media(message=photo)
            elif isinstance(message.media, MessageMediaDocument):
                if message.media.document.mime_type in ["image/jpeg", "image/png"]:
                    photo = message.media.document
                    photo = await bot.download_file(photo, file="propic.jpeg")
                    photo = io.BytesIO(photo)
                    photo.name = "image.jpeg"  # small hack for documents images
            else:
                await ppic.edit(INVALID_MEDIA)

        if photo:
            file = await bot.upload_file(photo)
            try:
                await bot(UploadProfilePhotoRequest(file))
                await ppic.edit(PP_CHANGED)

            except Exception as exc:
                if isinstance(exc, PhotoCropSizeSmallError):
                    await ppic.edit(PP_TOO_SMOL)
                elif isinstance(exc, ImageProcessFailedError):
                    await ppic.edit(PP_ERROR)
コード例 #11
0
ファイル: account.py プロジェクト: stykers/pagermaid
async def pfp(context):
    """ Sets your profile picture. """
    reply = await context.get_reply_message()
    photo = None
    await context.edit("Setting profile picture . . .")
    if reply.media:
        if isinstance(reply.media, MessageMediaPhoto):
            photo = await bot.download_media(message=reply.photo)
        elif "image" in reply.media.document.mime_type.split('/'):
            photo = await bot.download_file(reply.media.document)
        else:
            await context.edit("Unable to parse attachment as image.")

    if photo:
        try:
            await bot(UploadProfilePhotoRequest(await bot.upload_file(photo)))
            remove(photo)
            await context.edit("Profile picture has been updated.")
        except PhotoCropSizeSmallError:
            await context.edit(
                "The image dimensions are smaller than minimum requirement.")
        except ImageProcessFailedError:
            await context.edit(
                "An error occurred while the server is interpreting the command."
            )
        except PhotoExtInvalidError:
            await context.edit("Unable to parse attachment as image.")
コード例 #12
0
async def autopic(e):
    search = e.pattern_match.group(1)
    if not search:
        return await eor(e, get_string("autopic_1"), time=5)
    clls = autopicsearch(search)
    if len(clls) == 0:
        return await eor(e, get_string("autopic_2").format(search), time=5)
    await eor(e, get_string("autopic_3").format(search))
    udB.set("AUTOPIC", "True")
    ST = udB.get("SLEEP_TIME")
    SLEEP_TIME = int(ST) if ST else 1221
    while True:
        for lie in clls:
            ge = udB.get("AUTOPIC")
            if ge != "True":
                return
            au = "https://unsplash.com" + lie["href"]
            ct = r.get(au).content
            bsc = bs(ct, "html.parser", from_encoding="utf-8")
            ft = bsc.find_all("img", "oCCRx")
            li = ft[0]["src"]
            kar = "autopic.png"
            await download_file(li, kar)
            file = await e.client.upload_file(kar)
            await e.client(UploadProfilePhotoRequest(file))
            os.remove(kar)
            await asyncio.sleep(SLEEP_TIME)
コード例 #13
0
ファイル: main.py プロジェクト: lalas51/telegrma-avatarka
async def main():
    prev_update_time = datetime.now() - timedelta(minutes=1)
    await client(DeletePhotosRequest(await client.get_profile_photos('me')))
    file = await client.upload_file(bts)
    await client(UploadProfilePhotoRequest(file))
    prev_update_time = datetime.now()
    time.sleep(1)
コード例 #14
0
async def _(ult):
    ok = await eor(ult, "...")
    reply_message = await ult.get_reply_message()
    await ok.edit("`Downloading that picture...`")
    if not os.path.isdir(TMP_DOWNLOAD_DIRECTORY):
        os.makedirs(TMP_DOWNLOAD_DIRECTORY)
    photo = None
    try:
        photo = await ultroid_bot.download_media(reply_message, TMP_DOWNLOAD_DIRECTORY)
    except Exception as ex:
        await ok.edit("Error occured.\n`{}`".format(str(ex)))
    else:
        if photo:
            await ok.edit("`Uploading it to my profile...`")
            file = await ultroid_bot.upload_file(photo)
            try:
                await ultroid_bot(UploadProfilePhotoRequest(file))
            except Exception as ex:
                await ok.edit("Error occured.\n`{}`".format(str(ex)))
            else:
                await ok.edit("`My profile picture has been changed !`")
    await asyncio.sleep(10)
    await ok.delete()
    try:
        os.remove(photo)
    except Exception as ex:
        LOGS.exception(ex)
コード例 #15
0
ファイル: autopp.py プロジェクト: headshot001/PAPERPLANE
async def autopic(event):
    while True:
        downloaded_file_name = "./original_pic.png"
        photo = "./new_photo.png"
        shutil.copy(downloaded_file_name, photo)
        LT = datetime.datetime.now(pytz.timezone('Asia/Kolkata'))
        OT = LT.strftime(
            "root@ayush:~# python3\n\n>>>import datetime\n\n>>>localtime = datetime.datetime.now()\n\n>>>while True :\n\n...     print(' ',localtime)\n\n...     print(' ','HAVE A NICE DAY !')\n\n...     sleep(60)\n\n...else :\n\n...     return\n\n>>> %d.%m.%y %H:%M\n\n>>> HAVE A NICE DAY !"
        )
        img = Image.open(photo)
        drawn_text = ImageDraw.Draw(img)
        fnt = ImageFont.truetype(FONT_FILE_TO_USE, 25)
        drawn_text.text((40, 80), OT, align='left', font=fnt, fill='black')
        img.save(photo)
        file = await event.client.upload_file(photo)
        try:
            await event.client(UploadProfilePhotoRequest(file))
            os.remove(photo)
            await asyncio.sleep(60)
            n = 1
            await event.client(
                DeletePhotosRequest(await
                                    event.client.get_profile_photos("me",
                                                                    limit=n)))
        except:
            return
コード例 #16
0
ファイル: account.py プロジェクト: artxia/backup
async def pfp(context):
    """ Sets your profile picture. """
    reply = await context.get_reply_message()
    photo = None
    if not silent:
        await context.edit(lang('pfp_process'))
    if reply:
        if reply.media:
            if isinstance(reply.media, MessageMediaPhoto):
                photo = await bot.download_media(message=reply.photo)
            elif "image" in reply.media.document.mime_type.split('/'):
                photo = await bot.download_file(reply.media.document)
            else:
                await context.edit(
                    f"{lang('error_prefix')}{lang('pfp_e_notp')}")

    if photo:
        try:
            await bot(UploadProfilePhotoRequest(await bot.upload_file(photo)))
            try:
                remove(photo)
            except:
                pass
            await context.edit("头像修改成功啦 ~")
            return
        except PhotoCropSizeSmallError:
            await context.edit(f"{lang('error_prefix')}{lang('pfp_e_size')}")
        except ImageProcessFailedError:
            await context.edit(f"{lang('error_prefix')}{lang('pfp_e_img')}")
        except PhotoExtInvalidError:
            await context.edit(f"{lang('error_prefix')}{lang('pfp_e_notp')}")
    await context.edit(f"{lang('error_prefix')}{lang('pfp_e_notp')}")
    return
コード例 #17
0
async def _(ult):
    if not ult.is_reply:
        return await eor(ult, "`Reply to a Media..`", time=5)
    reply_message = await ult.get_reply_message()
    ok = await eor(ult, get_string("com_1"))
    replfile = await reply_message.download_media()
    file = await ult.client.upload_file(replfile)
    try:
        if "pic" in mediainfo(reply_message.media):
            await ult.client(UploadProfilePhotoRequest(file))
        else:
            await ult.client(UploadProfilePhotoRequest(video=file))
        await eod(ok, "`My Profile Photo has Successfully Changed !`")
    except Exception as ex:
        await eod(ok, "Error occured.\n`{}`".format(str(ex)))
    os.remove(replfile)
コード例 #18
0
ファイル: profile.py プロジェクト: RyuuXenon/botafk
async def set_profilepic(propic):
    """ For .profilepic command, change your profile picture in Telegram. """
    
    replymsg = await propic.get_reply_message()
    photo = None
    #Prevent Channel Bug to control Change Profile
    if propic.is_channel and not propic.is_group:
        await propic.edit("`Setpfp Commad isn't permitted on channels`")
        return
    if replymsg.media:
        if isinstance(replymsg.media, MessageMediaPhoto):
            photo = await propic.client.download_media(message=replymsg.photo)
        elif "image" in replymsg.media.document.mime_type.split('/'):
            photo = await propic.client.download_file(replymsg.media.document)
        else:
            await propic.edit(INVALID_MEDIA)

    if photo:
        try:
            await propic.client(
                UploadProfilePhotoRequest(await
                                          propic.client.upload_file(photo)))
            os.remove(photo)
            await propic.edit(PP_CHANGED)
        except PhotoCropSizeSmallError:
            await propic.edit(PP_TOO_SMOL)
        except ImageProcessFailedError:
            await propic.edit(PP_ERROR)
        except PhotoExtInvalidError:
            await propic.edit(INVALID_MEDIA)
コード例 #19
0
ファイル: profile.py プロジェクト: Kritinic/userbot
async def profile_photo(e):
    if not e.text[0].isalpha():
        message = await e.get_reply_message()
        photo = None
        if message.media:
            if isinstance(message.media, MessageMediaPhoto):
                photo = message.photo
                photo = await bot.download_media(message=photo)
            elif isinstance(message.media, MessageMediaDocument):
                if message.media.document.mime_type in [
                        'image/jpeg', 'image/png'
                ]:
                    photo = message.media.document
                    photo = await bot.download_file(photo, file="propic.jpeg")
                    photo = io.BytesIO(photo)
                    photo.name = 'image.jpeg'  # small hack for documents images
            else:
                await e.edit(
                    '```The extension of the media entity is invalid.```')

        if photo:
            file = await bot.upload_file(photo)
            try:
                await bot(UploadProfilePhotoRequest(file))
                await e.edit('```Profile Picture Changed```')

            except Exception as exc:
                if isinstance(exc, PhotoCropSizeSmallError):
                    await e.edit('```The image is too small```')
                elif isinstance(exc, ImageProcessFailedError):
                    await e.edit('```Failure while processing image```')
コード例 #20
0
async def main():
    """ This function is the main function of the program. """

    first_name = config["!SETTINGS!"]["first_name"]
    last_name = config["!SETTINGS!"]["last_name"]
    profile_photo = config["!SETTINGS!"]["profile_photo"]
    bio_act = config["!SETTINGS!"]["bio"]
    bio_link = config["!SETTINGS!"]["bio_link"]
    market = config["!SPOTIFY!"]["market"]
    image = ["", ""]

    while True:

        me = await client.get_me()

        if sp.currently_playing(market) is not None and sp.currently_playing(
                market)["item"] is not None:
            if me.first_name != "Listening to " + sp.currently_playing(
                    market)["item"]["name"]:
                if first_name == "True":
                    await client(
                        UpdateProfileRequest(
                            first_name="Listening to " +
                            sp.currently_playing(market)["item"]["name"]))
                if bio_act == "True":
                    if bio_link == "True":
                        await client(
                            UpdateProfileRequest(about=sp.currently_playing(
                                market)["item"]["external_urls"]["spotify"]))
                    else:
                        await client(
                            UpdateProfileRequest(
                                about=sp.currently_playing(market)["item"]
                                ["name"] + " - " + sp.currently_playing(
                                    market)["item"]["artists"][0]["name"]))
                image[1] = sp.currently_playing(market)["item"]["name"]

            if me.last_name != "by " + sp.currently_playing(market)["item"]["artists"][0]["name"] \
                    and last_name == "True":
                await client(
                    UpdateProfileRequest(last_name="by " +
                                         sp.currently_playing(market)["item"]
                                         ["artists"][0]["name"]))

            if profile_photo == "True":
                if image[0] != image[1]:
                    urllib.request.urlretrieve(
                        sp.currently_playing(market)["item"]["album"]["images"]
                        [0]["url"], "album.jpg")
                    await client(
                        DeletePhotosRequest((await
                                             client.get_profile_photos(me))))
                    await client(
                        UploadProfilePhotoRequest(
                            await client.upload_file("album.jpg")))
                    image[0] = image[1]
        print(image)

        time.sleep(60)  # the only fix that works for now
コード例 #21
0
def set_photo(client):
    print('Uploading new profile photo...')
    try:
        photo = client(
            UploadProfilePhotoRequest(file=client.upload_file('profile.jpg')))
        print('Successfully uploaded photo!')
    except:
        print('Error! Failed to changed photo!')
コード例 #22
0
async def main():

    while True:
        await client(DeletePhotosRequest(await
                                         client.get_profile_photos('me')))
        await client(UpdateProfileRequest(about='Forza Napoli'))
        await client(
            UploadProfilePhotoRequest(await client.upload_file('123.jpg')))
        time.sleep(30)
        await client(UpdateProfileRequest(about='Die Schwarzgelben'))
        await client(
            UploadProfilePhotoRequest(await client.upload_file('1234.jpg')))
        time.sleep(30)
        await client(UpdateProfileRequest(about='Aupa Atleti'))
        await client(
            UploadProfilePhotoRequest(await client.upload_file('12345.jpg')))
        time.sleep(30)
コード例 #23
0
async def clone(cloner):
    """ Clone first name, last name, bio and profile picture """
    reply_message = cloner.reply_to_msg_id
    message = await cloner.get_reply_message()
    if reply_message:
        input_ = message.sender.id
    else:
        input_ = cloner.pattern_match.group(1)

    if not input_:
        await cloner.edit("`Please reply to user or input username`")
        await asyncio.sleep(5)
        await cloner.delete()
        return

    await cloner.edit("`Cloning...`")

    try:
        user = await cloner.client(GetFullUserRequest(input_))
    except ValueError:
        await cloner.edit("`Invalid username!`")
        await asyncio.sleep(2)
        await cloner.delete()
        return
    me = await cloner.client.get_me()

    if USER_DATA or os.path.exists(PHOTO):
        await cloner.edit("`First revert!`")
        await asyncio.sleep(2)
        await cloner.delete()
        return
    mychat = await cloner.client(GetFullUserRequest(me.id))
    USER_DATA.update(
        {
            "first_name": mychat.user.first_name or "",
            "last_name": mychat.user.last_name or "",
            "about": mychat.about or "",
        }
    )
    await cloner.client(
        UpdateProfileRequest(
            first_name=user.user.first_name or "",
            last_name=user.user.last_name or "",
            about=user.about or "",
        )
    )
    if not user.profile_photo:
        await cloner.edit("`User not have profile photo, cloned name and bio...`")
        await asyncio.sleep(5)
        await cloner.delete()
        return
    await cloner.client.download_profile_photo(user.user.id, PHOTO)
    await cloner.client(
        UploadProfilePhotoRequest(file=await cloner.client.upload_file(PHOTO))
    )
    await cloner.edit("`Profile is successfully cloned!`")
    await asyncio.sleep(3)
    await cloner.delete()
コード例 #24
0
ファイル: clone.py プロジェクト: anehajahlu/Deathnotefars
async def clone(cloner):
    """ Clone first name, last name, bio and profile picture """
    reply_message = cloner.reply_to_msg_id
    message = await cloner.get_reply_message()
    if reply_message:
        input_ = message.sender.id
    else:
        input_ = cloner.pattern_match.group(1)

    if not input_:
        await cloner.edit("`Maaf Kamu Harus REPLY Pesan Terlebih Dahulu!`")
        await asyncio.sleep(5)
        await cloner.delete()
        return

    await cloner.edit("`Kamu Sabar, Sedang Diproses CLONING!...`")

    try:
        user = await cloner.client(GetFullUserRequest(input_))
    except ValueError:
        await cloner.edit("`Invalid username!`")
        await asyncio.sleep(2)
        await cloner.delete()
        return
    me = await cloner.client.get_me()

    if USER_DATA or os.path.exists(PHOTO):
        await cloner.edit("`First revert!`")
        await asyncio.sleep(2)
        await cloner.delete()
        return
    mychat = await cloner.client(GetFullUserRequest(me.id))
    USER_DATA.update(
        {
            "first_name": mychat.user.first_name or "",
            "last_name": mychat.user.last_name or "",
            "about": mychat.about or "",
        }
    )
    await cloner.client(
        UpdateProfileRequest(
            first_name=user.user.first_name or "",
            last_name=user.user.last_name or "",
            about=user.about or "",
        )
    )
    if not user.profile_photo:
        await cloner.edit("`User not have profile photo, cloned name and bio...`")
        await asyncio.sleep(5)
        await cloner.delete()
        return
    await cloner.client.download_profile_photo(user.user.id, PHOTO)
    await cloner.client(
        UploadProfilePhotoRequest(file=await cloner.client.upload_file(PHOTO))
    )
    await cloner.edit("`Yeahh Profil Sudah Diubah & Sudah Di-Cloned!`")
    await asyncio.sleep(3)
    await cloner.delete()
コード例 #25
0
async def clone(cloner):
    """ Clone first name, last name, bio and profile picture """
    reply_message = cloner.reply_to_msg_id
    message = await cloner.get_reply_message()
    if reply_message:
        input_ = message.sender.id
    else:
        input_ = cloner.pattern_match.group(1)

    if not input_:
        await cloner.edit(
            "`Harap balas ke pungguna atau masukkan nama pengguna`")
        await asyncio.sleep(5)
        await cloner.delete()
        return

    await cloner.edit("`Kloning...`")

    try:
        user = await cloner.client(GetFullUserRequest(input_))
    except ValueError:
        await cloner.edit("`Nama pengguna tidak valid!`")
        await asyncio.sleep(2)
        await cloner.delete()
        return
    me = await cloner.client.get_me()

    if USER_DATA or os.path.exists(PHOTO):
        await cloner.edit("`Kembalikan dulu!`")
        await asyncio.sleep(2)
        await cloner.delete()
        return
    mychat = await cloner.client(GetFullUserRequest(me.id))
    USER_DATA.update({
        "first_name": mychat.user.first_name or "",
        "last_name": mychat.user.last_name or "",
        "about": mychat.about or "",
    })
    await cloner.client(
        UpdateProfileRequest(
            first_name=user.user.first_name or "",
            last_name=user.user.last_name or "",
            about=user.about or "",
        ))
    if not user.profile_photo:
        await cloner.edit(
            "`Pengguna tidak memiliki foto profil.\nKloning nama dan bio...`")
        await asyncio.sleep(5)
        await cloner.delete()
        return
    await cloner.client.download_profile_photo(user.user.id, PHOTO)
    await cloner.client(
        UploadProfilePhotoRequest(file=await cloner.client.upload_file(PHOTO)))
    await cloner.edit("`Profil berhasil di-klon!`")
    await asyncio.sleep(3)
    await cloner.delete()
コード例 #26
0
ファイル: main.py プロジェクト: skiter847/AvatarClock
def main():
    previous_time = ''
    with TelegramClient(SESSION_FILE, API_ID, API_HASH) as client:
        while True:
            if not previous_time == current_time():
                previous_time = current_time()
                create_image(current_time())
                image = client.upload_file('clock.png')
                client(DeletePhotosRequest(client.get_profile_photos('me')))
                client(UploadProfilePhotoRequest(image))
コード例 #27
0
async def main():
    prev_update_time = datetime.now() - timedelta(minutes=1)

    while True:
        if time_has_changed(prev_update_time):
            bts = generate_time_image_bytes(datetime.now(args.tz).replace(tzinfo=None))
            await client(DeletePhotosRequest(await client.get_profile_photos('me')))
            file = await client.upload_file(bts)
            await client(UploadProfilePhotoRequest(file))
            prev_update_time = datetime.now()
            time.sleep(1)
コード例 #28
0
async def main():
    index = minutes_total() + int(config.OFFSET)
    if index < 0:
        index = index + 1440
    elif index >= 1440:
        index = index - 1440
    prev_avatar = await client.get_profile_photos('me')
    filename = config.IMG_DIR + f'/{index:04}.' + config.IMG_EXT
    await client(UploadProfilePhotoRequest(await client.upload_file(filename)))
    await client(DeletePhotosRequest(prev_avatar))
    print('Avatar changed: ' + filename)
コード例 #29
0
def main():
    previous_time = ''
    with TelegramClient(config.session_name, config.api_id, config.api_hash) as client:
        while True:
            if not previous_time == get_current_time():
                current_time = get_current_time()
                previous_time = current_time
                generate_image(current_time)
                image = client.upload_file('time_image.jpg')
                client(DeletePhotosRequest(client.get_profile_photos('me')))
                client(UploadProfilePhotoRequest(image))
コード例 #30
0
async def main():
    last_time = photo_changer.time(':')[1]
    while True:
        now = photo_changer.time(':')[1]
        if now != last_time:
            photo_changer.save_profile_photo()
            await client(
                DeletePhotosRequest(await client.get_profile_photos("me")))
            with open(PHOTO_NAME, 'rb') as photo:
                file = await client.upload_file(photo)
            await client(UploadProfilePhotoRequest(file))
            last_time = now
        sleep(5)