forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py
110 lines (94 loc) · 3.17 KB
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# 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ᴏ Pʟᴜɢɪɴ 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ᴏ Pʟᴜɢɪɴ 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,
)