Files
Ultroid-fork/plugins/get_addons.py
1Danish-00 386eff647c v0.0.9 18/07/2021
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Amit Sharma <48654350+buddhhu@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>
2021-07-18 17:47:15 +05:30

51 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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}getaddons <raw link to code>`
Load Plugins from the given raw link.
"""
import requests
from pyUltroid.utils import load_addons
from . import *
@ultroid_cmd(pattern="getaddons ?(.*)")
async def get_the_addons_lol(event):
thelink = event.pattern_match.group(1)
xx = await eor(event, get_string("com_1"))
fool = "Please provide a raw link!"
if thelink is None:
return await eod(xx, fool, time=10)
split_thelink = thelink.split("/")
if "raw" in split_thelink or "raw.githubusercontent.com" in split_thelink:
pass
else:
return await eod(xx, fool, time=10)
name_of_it = split_thelink[(len(split_thelink) - 1)]
plug = requests.get(thelink).text
fil = f"addons/{name_of_it}"
await xx.edit("Packing the codes...")
uult = open(fil, "w", encoding="utf-8")
uult.write(plug)
uult.close
await xx.edit("Packed. Now loading the plugin..")
shortname = name_of_it.split(".")[0]
try:
load_addons(shortname)
await eod(xx, f"**Sᴇssғʟʟʏ Lᴀᴅᴇᴅ** `{shortname}`")
except Exception as e:
await eod(
xx,
f"**Could not load** `{shortname}` **because of the following error.**\n`{str(e)}`",
time=3,
)