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