Files
Ultroid-fork/plugins/core.py
Anonymous 4e65f218f5 Ultroid v0.0.8 | 17-6-21
Co-authored-by: Aditya <me@xditya.me>
Co-authored-by: Danish <danish@ultroid.tech>
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>
Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com>
2021-06-17 21:18:55 +05:30

111 lines
3.2 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}install <reply to plugin>`
To install the plugin,
`{i}install f`
To force Install.
• `{i}uninstall <plugin name>`
To unload and remove the plugin.
• `{i}load <plugin name>`
To load unloaded unofficial plugin.
• `{i}unload <plugin name>`
To unload unofficial plugin.
• `{i}help <plugin name>`
Shows you a help menu (like this) for every plugin.
"""
import os
from . import *
@ultroid_cmd(
pattern="install",
)
async def install(event):
if not event.out and not is_fullsudo(event.sender_id):
return await eod(event, "`This Command Is Sudo Restricted.`")
await safeinstall(event)
@ultroid_cmd(
pattern=r"unload ?(.*)",
)
async def unload(event):
shortname = event.pattern_match.group(1)
if not shortname:
await eor(event, "`Give name of plugin which u want to unload`")
return
lsd = os.listdir("addons")
lst = os.listdir("plugins")
zym = shortname + ".py"
if zym in lsd:
try:
un_plug(shortname)
await eod(event, f"**Uɴʟᴀᴅᴇᴅ** `{shortname}` **Sᴇssғʟʟʏ.**", time=3)
except Exception as ex:
return await eor(event, str(ex))
elif zym in lst:
return await eod(event, "**Y Cᴀɴ'ᴛ Uɴʟᴀᴅ Oғғɪɪᴀʟ Pʟɢɪɴs**", time=3)
else:
return await eod(event, f"**Nɢɪɴ Nᴀᴍᴇᴅ** `{shortname}`", time=3)
@ultroid_cmd(
pattern=r"uninstall ?(.*)",
)
async def uninstall(event):
shortname = event.pattern_match.group(1)
if not shortname:
await eor(event, "`Give name of plugin which u want to uninstall`")
return
lsd = os.listdir("addons")
lst = os.listdir("plugins")
zym = shortname + ".py"
if zym in lsd:
try:
un_plug(shortname)
await eod(event, f"**Uɴɪɴsᴛᴀʟʟᴇᴅ** `{shortname}` **Sᴇssғʟʟʏ.**", time=3)
os.remove(f"addons/{shortname}.py")
except Exception as ex:
return await eor(event, str(ex))
elif zym in lst:
return await eod(event, "**Y Cᴀɴ'ᴛ Uɴɪɴsᴛᴀʟʟ Oғғɪɪᴀʟ Pʟɢɪɴs**", time=3)
else:
return await eod(event, f"**Nɢɪɴ Nᴀᴍᴇᴅ** `{shortname}`", time=3)
@ultroid_cmd(
pattern=r"load ?(.*)",
)
async def load(event):
shortname = event.pattern_match.group(1)
if not shortname:
await eor(event, "`Give name of plugin which u want to load`")
return
try:
try:
un_plug(shortname)
except BaseException:
pass
load_addons(shortname)
await eod(event, f"**Sᴇssғʟʟʏ Lᴀᴅᴇᴅ** `{shortname}`", time=3)
except Exception as e:
await eod(
event,
f"**Could not load** `{shortname}` **because of the following error.**\n`{str(e)}`",
time=3,
)