Files
Ultroid-fork/plugins/autopic.py
1Danish-00 6f44b386aa v0.2 11/10/2021
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
Co-authored-by: Amit Sharma <buddhhu@users.noreply.github.com>
Co-authored-by: TechiError <techierror@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Sonya Nikiforova <Sonniki@users.noreply.github.com>
Co-authored-by: M̲αραт <Marty2509@users.noreply.github.com>
Co-authored-by: Muhamad Risman Aziz <mrismanaziz@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
2021-10-11 00:27:23 +05:30

59 lines
1.8 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2021 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}autopic <search query>`
Will change your profile pic at defined intervals with pics related to the given topic.
• `{i}stoppic`
Stop the AutoPic command.
"""
import asyncio
import os
from random import shuffle
from pyUltroid.functions.misc import unsplashsearch
from telethon.tl.functions.photos import UploadProfilePhotoRequest
from . import download_file, eor, get_string, udB, ultroid_cmd
@ultroid_cmd(pattern="autopic ?(.*)")
async def autopic(e):
search = e.pattern_match.group(1)
if not search:
return await eor(e, get_string("autopic_1"), time=5)
e = await eor(e, get_string("com_1"))
clls = await unsplashsearch(search, limit=50)
if not clls:
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:
if udB.get("AUTOPIC") != "True":
return
kar = await download_file(lie, "autopic.png")
file = await e.client.upload_file(kar)
await e.client(UploadProfilePhotoRequest(file))
os.remove(kar)
await asyncio.sleep(SLEEP_TIME)
shuffle(clls)
@ultroid_cmd(pattern="stoppic$")
async def stoppo(ult):
gt = udB.get("AUTOPIC")
if gt != "True":
return await eor(ult, get_string("autopic_4"), time=5)
udB.set("AUTOPIC", "None")
await eor(ult, get_string("autopic_5"), time=5)