Files
Ultroid-fork/plugins/get_addons.py
Devesh Pal 6c7af44f09 Ultroid v0.1 Updates 13.09.2021
Co-authored-by: Danish <danish@ultroid.tech>
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-09-13 01:03:39 +05:30

48 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.startup.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 eor(xx, fool, time=10)
split_thelink = thelink.split("/")
if "raw" not in split_thelink:
return await eor(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...")
with open(fil, "w", encoding="utf-8") as uult:
uult.write(plug)
await xx.edit("Packed. Now loading the plugin..")
shortname = name_of_it.split(".")[0]
try:
load_addons(shortname)
await eor(xx, f"**Sᴇssғʟʟʏ Lᴀᴅᴇᴅ** `{shortname}`", time=15)
except Exception as e:
await eod(
xx,
f"**Could not load** `{shortname}` **because of the following error.**\n`{e}`",
time=3,
)