Files
Ultroid-fork/plugins/webshot.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

39 lines
1.0 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}webshot <url>`
Get a screenshot of the webpage.
"""
import os
from htmlwebshot import WebShot
from . import eor, get_string, is_url_ok, ultroid_cmd
@ultroid_cmd(pattern="webshot ?(.*)")
async def webss(event):
xx = await eor(event, get_string("com_1"))
xurl = event.pattern_match.group(1)
if not xurl:
return await eor(xx, get_string("wbs_1"), time=5)
elif not is_url_ok(xurl):
return await eor(xx, get_string("wbs_2"), time=5)
shot = WebShot(quality=88, flags=["--enable-javascript", "--no-stop-slow-scripts"])
pic = await shot.create_pic_async(url=xurl)
await xx.reply(
get_string("wbs_3").format(xurl),
file=pic,
link_preview=False,
force_document=True,
)
os.remove(pic)
await xx.delete()