Team Ai
Apppublic

azils3/bash

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
misc.py141 linesDownload Raw Back to plugins
1# Ultroid - UserBot2#3# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >4# PLease read the GNU Affero General Public License in5# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.6"""7✘ Commands Available -8 9• `{i}eod`10    `Get Event of the Today`11 12• `{i}pntrst <link/id>`13    Download and send pinterest pins14 15• `{i}gadget <search query>`16    Gadget Search from Telegram.17 18• `{i}randomuser`19   Generate details about a random user.20 21• `{i}ascii <reply image>`22    Convert replied image into html.23"""24 25import os26from datetime import datetime as dt27 28from bs4 import BeautifulSoup as bs29 30try:31    from htmlwebshot import WebShot32except ImportError:33    WebShot = None34try:35    from img2html.converter import Img2HTMLConverter36except ImportError:37    Img2HTMLConverter = None38 39from . import async_searcher, get_random_user_data, get_string, re, ultroid_cmd40 41 42@ultroid_cmd(pattern="eod$")43async def diela(e):44    m = await e.eor(get_string("com_1"))45    li = "https://daysoftheyear.com"46    te = "🎊 **Events of the Day**\n\n"47    da = dt.now()48    month = da.strftime("%b")49    li += f"/days/{month}/" + da.strftime("%F").split("-")[2]50    ct = await async_searcher(li, re_content=True)51    bt = bs(ct, "html.parser", from_encoding="utf-8")52    ml = bt.find_all("a", "js-link-target", href=re.compile("daysoftheyear.com/days"))53    for eve in ml[:5]:54        te += f'• [{eve.text}]({eve["href"]})\n'55    await m.edit(te, link_preview=False)56 57 58@ultroid_cmd(59    pattern="pntrst( (.*)|$)",60)61async def pinterest(e):62    m = e.pattern_match.group(1).strip()63    if not m:64        return await e.eor("`Give pinterest link.`", time=3)65    soup = await async_searcher(66        "https://www.expertstool.com/download-pinterest-video/",67        data={"url": m},68        post=True,69    )70    try:71        _soup = bs(soup, "html.parser").find("table").tbody.find_all("tr")72    except BaseException:73        return await e.eor("`Wrong link or private pin.`", time=5)74    file = _soup[1] if len(_soup) > 1 else _soup[0]75    file = file.td.a["href"]76    await e.client.send_file(e.chat_id, file, caption=f"Pin:- {m}")77 78 79@ultroid_cmd(pattern="gadget( (.*)|$)")80async def mobs(e):81    mat = e.pattern_match.group(1).strip()82    if not mat:83        await e.eor("Please Give a Mobile Name to look for.")84    query = mat.replace(" ", "%20")85    jwala = f"https://gadgets.ndtv.com/search?searchtext={query}"86    c = await async_searcher(jwala)87    b = bs(c, "html.parser", from_encoding="utf-8")88    co = b.find_all("div", "rvw-imgbox")89    if not co:90        return await e.eor("No Results Found!")91    bt = await e.eor(get_string("com_1"))92    out = "**📱 Mobile / Gadgets Search**\n\n"93    li = co[0].find("a")94    imu, title = None, li.find("img")["title"]95    cont = await async_searcher(li["href"])96    nu = bs(cont, "html.parser", from_encoding="utf-8")97    req = nu.find_all("div", "_pdsd")98    imu = nu.find_all(99        "img", src=re.compile("https://i.gadgets360cdn.com/products/large/")100    )101    if imu:102        imu = imu[0]["src"].split("?")[0] + "?downsize=*:420&output-quality=80"103    out += f"☑️ **[{title}]({li['href']})**\n\n"104    for fp in req:105        ty = fp.findNext()106        out += f"- **{ty.text}** - `{ty.findNext().text}`\n"107    out += "_"108    if imu == []:109        imu = None110    await e.reply(out, file=imu, link_preview=False)111    await bt.delete()112 113 114@ultroid_cmd(pattern="randomuser")115async def _gen_data(event):116    x = await event.eor(get_string("com_1"))117    msg, pic = await get_random_user_data()118    await event.reply(file=pic, message=msg)119    await x.delete()120 121 122@ultroid_cmd(123    pattern="ascii( (.*)|$)",124)125async def _(e):126    if not Img2HTMLConverter:127        return await e.eor("'img2html-converter' not installed!")128    if not e.reply_to_msg_id:129        return await e.eor(get_string("ascii_1"))130    m = await e.eor(get_string("ascii_2"))131    img = await (await e.get_reply_message()).download_media()132    char = e.pattern_match.group(1).strip() or "■"133    converter = Img2HTMLConverter(char=char)134    html = converter.convert(img)135    shot = WebShot(quality=85)136    pic = await shot.create_pic_async(html=html)137    await m.delete()138    await e.reply(file=pic)139    os.remove(pic)140    os.remove(img)141