Team Ai
Apppublic

azils3/bash

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
unsplash.py37 linesDownload Raw Back to plugins
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available -9 10• {i}unsplash <search query> ; <no of pics>11    Unsplash Image Search.12"""13 14from pyUltroid.fns.misc import unsplashsearch15 16from . import asyncio, download_file, get_string, os, ultroid_cmd17 18 19@ultroid_cmd(pattern="unsplash( (.*)|$)")20async def searchunsl(ult):21    match = ult.pattern_match.group(1).strip()22    if not match:23        return await ult.eor("Give me Something to Search")24    num = 525    if ";" in match:26        num = int(match.split(";")[1])27        match = match.split(";")[0]28    tep = await ult.eor(get_string("com_1"))29    res = await unsplashsearch(match, limit=num)30    if not res:31        return await ult.eor(get_string("unspl_1"), time=5)32    CL = [download_file(rp, f"{match}-{e}.png") for e, rp in enumerate(res)]33    imgs = [z[0] for z in (await asyncio.gather(*CL)) if z]34    await ult.respond(f"Uploaded {len(imgs)} Images!", file=imgs)35    await tep.delete()36    [os.remove(img) for img in imgs]37