Team Ai
Apppublic

azils3/bash

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
specialtools.py392 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}wspr <username>`11    Send secret message..12 13• `{i}q <color-optional>`14• `{i}q @username`15• `{i}q r <color-optional>`16• `{i}q count` : `multiple quotes`17    Create quotes..18 19• `{i}sticker <query>`20    Search Stickers as Per ur Wish..21 22• `{i}getaudio <reply to an audio>`23    Download Audio To put in ur Desired Video/Gif.24 25• `{i}addaudio <reply to Video/gif>`26    It will put the above audio to the replied video/gif.27 28• `{i}dob <date of birth>`29    Put in dd/mm/yy Format only(eg .dob 01/01/1999).30 31• `{i}wall <query>`32    Search Hd Wallpaper as Per ur Wish..33"""34import os35import time36from datetime import datetime as dt37from random import choice38 39import pytz, asyncio40from bs4 import BeautifulSoup as bs41from telethon.tl.types import DocumentAttributeVideo42from requests import Session43from cloudscraper import create_scraper44from pyUltroid.fns.tools import get_google_images, metadata45 46from . import (47    HNDLR,48    ULTConfig,49    async_searcher,50    bash,51    downloader,52    eod,53    get_string,54    mediainfo,55    quotly,56    ultroid_bot,57    ultroid_cmd,58    uploader,59)60from .beautify import all_col61 62File = []63scraper = create_scraper()64 65@ultroid_cmd(66    pattern="getaudio$",67)68async def daudtoid(e):69    if not e.reply_to:70        return await eod(e, get_string("spcltool_1"))71    r = await e.get_reply_message()72    if not mediainfo(r.media).startswith(("audio", "video")):73        return await eod(e, get_string("spcltool_1"))74    xxx = await e.eor(get_string("com_1"))75    dl = r.file.name or "input.mp4"76    c_time = time.time()77    file = await downloader(78        f"resources/downloads/{dl}",79        r.media.document,80        xxx,81        c_time,82        f"Downloading {dl}...",83    )84 85    File.append(file.name)86    await xxx.edit(get_string("spcltool_2"))87 88 89@ultroid_cmd(90    pattern="addaudio$",91)92async def adaudroid(e):93    if not e.reply_to:94        return await eod(e, get_string("spcltool_3"))95    r = await e.get_reply_message()96    if not mediainfo(r.media).startswith("video"):97        return await eod(e, get_string("spcltool_3"))98    if not (File and os.path.exists(File[0])):99        return await e.edit(f"`First reply an audio with {HNDLR}addaudio`")100    xxx = await e.eor(get_string("com_1"))101    dl = r.file.name or "input.mp4"102    c_time = time.time()103    file = await downloader(104        f"resources/downloads/{dl}",105        r.media.document,106        xxx,107        c_time,108        f"Downloading {dl}...",109    )110 111    await xxx.edit(get_string("spcltool_5"))112    await bash(113        f'ffmpeg -i "{file.name}" -i "{File[0]}" -shortest -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4'114    )115    out = "output.mp4"116    mmmm = await uploader(out, out, time.time(), xxx, f"Uploading {out}...")117    data = await metadata(out)118    width = data["width"]119    height = data["height"]120    duration = data["duration"]121    attributes = [122        DocumentAttributeVideo(123            duration=duration, w=width, h=height, supports_streaming=True124        )125    ]126    await e.client.send_file(127        e.chat_id,128        mmmm,129        thumb=ULTConfig.thumb,130        attributes=attributes,131        force_document=False,132        reply_to=e.reply_to_msg_id,133    )134    await xxx.delete()135    os.remove(out)136    os.remove(file.name)137    File.clear()138    os.remove(File[0])139 140 141@ultroid_cmd(142    pattern=r"dob( (.*)|$)",143)144async def hbd(event):145    match = event.pattern_match.group(1).strip()146    if not match:147        return await event.eor(get_string("spcltool_6"))148    if event.reply_to_msg_id:149        kk = await event.get_reply_message()150        nam = await kk.get_sender()151        name = nam.first_name152    else:153        name = ultroid_bot.me.first_name154    zn = pytz.timezone("Asia/Kolkata")155    abhi = dt.now(zn)156    kk = match.split("/")157    p = kk[0]158    r = kk[1]159    s = kk[2]160    day = int(p)161    month = r162    try:163        jn = dt.strptime(match, "%d/%m/%Y")164    except BaseException:165        return await event.eor(get_string("spcltool_6"))166    jnm = zn.localize(jn)167    zinda = abhi - jnm168    barsh = (zinda.total_seconds()) / (365.242 * 24 * 3600)169    saal = int(barsh)170    mash = (barsh - saal) * 12171    mahina = int(mash)172    divas = (mash - mahina) * (365.242 / 12)173    din = int(divas)174    samay = (divas - din) * 24175    ghanta = int(samay)176    pehl = (samay - ghanta) * 60177    mi = int(pehl)178    sec = (pehl - mi) * 60179    slive = int(sec)180    y = int(s) + saal + 1181    m = int(r)182    brth = dt(y, m, day)183    cm = dt(abhi.year, brth.month, brth.day)184    ish = (cm - abhi.today()).days + 1185    dan = ish186    if dan == 0:187        hp = "`Happy BirthDay To U🎉🎊`"188    elif dan < 0:189        okk = 365 + ish190        hp = f"{okk} Days Left 🥳"191    elif dan > 0:192        hp = f"{ish} Days Left 🥳"193    if month == "01":194        sign = "Capricorn" if (day < 20) else "Aquarius"195    elif month == "02":196        sign = "Aquarius" if (day < 19) else "Pisces"197    elif month == "03":198        sign = "Pisces" if (day < 21) else "Aries"199    elif month == "04":200        sign = "Aries" if (day < 20) else "Taurus"201    elif month == "05":202        sign = "Taurus" if (day < 21) else "Gemini"203    elif month == "06":204        sign = "Gemini" if (day < 21) else "Cancer"205    elif month == "07":206        sign = "Cancer" if (day < 23) else "Leo"207    elif month == "08":208        sign = "Leo" if (day < 23) else "Virgo"209    elif month == "09":210        sign = "Virgo" if (day < 23) else "Libra"211    elif month == "10":212        sign = "Libra" if (day < 23) else "Scorpio"213    elif month == "11":214        sign = "Scorpio" if (day < 22) else "Sagittarius"215    elif month == "12":216        sign = "Sagittarius" if (day < 22) else "Capricorn"217    json = await async_searcher(218        f"https://aztro.sameerkumar.website/?sign={sign}&day=today",219        post=True,220        re_json=True,221    )222    dd = json.get("current_date")223    ds = json.get("description")224    lt = json.get("lucky_time")225    md = json.get("mood")226    cl = json.get("color")227    ln = json.get("lucky_number")228    await event.delete()229    await event.client.send_message(230        event.chat_id,231        f"""232    Name -: {name}233 234D.O.B -:  {match}235 236Lived -:  {saal}yr, {mahina}m, {din}d, {ghanta}hr, {mi}min, {slive}sec237 238Birthday -: {hp}239 240Zodiac -: {sign}241 242**Horoscope On {dd} -**243 244`{ds}`245 246    Lucky Time :-        {lt}247    Lucky Number :-   {ln}248    Lucky Color :-        {cl}249    Mood :-                   {md}250    """,251        reply_to=event.reply_to_msg_id,252    )253 254session = Session()255 256@ultroid_cmd(pattern="sticker( (.*)|$)")257async def _(event):258    x = event.pattern_match.group(1).strip()259    if not x:260        return await event.eor("`Give something to search`")261    uu = await event.eor(get_string("com_1"))262    263    headers = {264        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'265    }266    267    max_retries = 3268    retry_count = 0269    270    while retry_count < max_retries:271        try:272            response = scraper.get(273                f"https://combot.org/telegram/stickers?q={x}",274                headers=headers275            ).content276            277            # Check if response contains Cloudflare challenge278            if "Just a moment..." in response.decode():279                retry_count += 1280                await asyncio.sleep(2) # Wait before retry281                continue282                283            z = bs(response, "html.parser")284            packs = z.find_all("a", {"class": "stickerset__title"})285            286            if not packs:287                return await uu.edit(get_string("spcltool_9"))288                289            break # Success - exit loop290            291        except Exception as er:292            retry_count += 1293            await asyncio.sleep(2)294            continue295    296    if retry_count >= max_retries:297        return await uu.edit("`Failed to fetch stickers after multiple retries`")298    try:299        sticks = {}300        for pack in packs:301            href = pack.get("href")302            title = pack.text.strip()303            if href:304                href = f"https://t.me/addstickers/{href.split('/')[-1]}"305                sticks[href] = title306 307        if not sticks:308            return await uu.edit(get_string("spcltool_9"))309 310        a = "SᴛɪᴄᴋEʀs Aᴠᴀɪʟᴀʙʟᴇ ~\n\n"311        for href, title in sticks.items():312            a += f"<a href={href}>{title}</a>\n"313        await uu.edit(a, parse_mode="html")314        315    except Exception as e:316        await uu.edit(f"`Error: {str(e)}`\nTry again later.")317 318@ultroid_cmd(pattern="wall( (.*)|$)")319async def wall(event):320    inp = event.pattern_match.group(1).strip()321    if not inp:322        return await event.eor("`Give me something to search..`")323    nn = await event.eor(get_string("com_1"))324    query = f"hd {inp}"325    images = await get_google_images(query)326    for z in range(5):327        await event.client.send_file(event.chat_id, file=images[z]["original"])328    await nn.delete()329 330 331@ultroid_cmd(pattern="q( (.*)|$)", manager=True, allow_pm=True)332async def quott_(event):333    match = event.pattern_match.group(1).strip()334    if not event.is_reply:335        return await event.eor("`Reply to Message..`")336    msg = await event.eor(get_string("com_1"))337    reply = await event.get_reply_message()338    replied_to, reply_ = None, None339    if match:340        spli_ = match.split(maxsplit=1)341        if (spli_[0] in ["r", "reply"]) or (342            spli_[0].isdigit() and int(spli_[0]) in range(1, 21)343        ):344            if spli_[0].isdigit():345                if not event.client._bot:346                    reply_ = await event.client.get_messages(347                        event.chat_id,348                        min_id=event.reply_to_msg_id - 1,349                        reverse=True,350                        limit=int(spli_[0]),351                    )352                else:353                    id_ = reply.id354                    reply_ = []355                    for msg_ in range(id_, id_ + int(spli_[0])):356                        msh = await event.client.get_messages(event.chat_id, ids=msg_)357                        if msh:358                            reply_.append(msh)359            else:360                replied_to = await reply.get_reply_message()361            try:362                match = spli_[1]363            except IndexError:364                match = None365    user = None366    if not reply_:367        reply_ = reply368    if match:369        match = match.split(maxsplit=1)370    if match:371        if match[0].startswith("@") or match[0].isdigit():372            try:373                match_ = await event.client.parse_id(match[0])374                user = await event.client.get_entity(match_)375            except ValueError:376                pass377            match = match[1] if len(match) == 2 else None378        else:379            match = match[0]380    if match == "random":381        match = choice(all_col)382    try:383        file = await quotly.create_quotly(384            reply_, bg=match, reply=replied_to, sender=user385        )386    except Exception as er:387        return await msg.edit(str(er))388    message = await reply.reply("Quotly by Ultroid", file=file)389    os.remove(file)390    await msg.delete()391    return message392 
azils3/bash · Team Ai