Files
Ultroid-fork/plugins/webshot.py
Danish bef7479be0 Bug fixes V0.0.5
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Danish <danish@ultroid.tech>
Co-authored-by: buddhhu <buddhuu@users.noreply.github.com>
Co-authored-by: sppidy <sppidy@users.noreply.github.com>
Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com>
Co-authored-by: divkix <divkix@users.noreply.github.com>
Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com>
Co-authored-by: Programming Error <error@notavailable.live>
Co-authored-by: New-dev0 <New-dev0@notavailable.live>
2021-04-15 18:37:02 +05:30

58 lines
1.5 KiB
Python

# Ultroid - UserBot
# Copyright (C) 2020 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 requests
from . import *
@ultroid_cmd(pattern="webshot")
async def webss(event):
xx = await eor(event, get_string("com_1"))
mssg = event.text.split(" ", maxsplit=2)
try:
xurl = mssg[1]
except IndexError:
return await eod(xx, "`Give a URL please!`", time=5)
try:
requests.get(xurl)
except requests.ConnectionError:
return await eod(xx, "Invalid URL!", time=5)
except requests.exceptions.MissingSchema:
try:
r = requests.get("https://" + xurl)
except requests.ConnectionError:
try:
r2 = requests.get("http://" + xurl)
except requests.ConnectionError:
return await eod(xx, "Invalid URL!", time=5)
lnk = f"https://shot.screenshotapi.net/screenshot?url={xurl}"
ok = requests.get(lnk).json()
try:
sshot = ok["screenshot"]
except BaseException:
return await eod(xx, "Something Went Wrong :(", time=10)
await xx.reply(
f"**WebShot Generated**\n**URL**: {xurl}",
file=sshot,
link_preview=False,
force_document=True,
)
await xx.delete()
HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=HNDLR)}"})