mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 16:25:36 +00:00
Minor update;
This commit is contained in:
parent
b1162af681
commit
84c45d321a
@ -79,8 +79,7 @@ class PluginsLoader:
|
|||||||
|
|
||||||
async def load(self):
|
async def load(self):
|
||||||
self.log.debug("Loading plugins...")
|
self.log.debug("Loading plugins...")
|
||||||
files = os.listdir(self.plugins_dir)
|
for file in os.listdir(self.plugins_dir):
|
||||||
for file in files:
|
|
||||||
file_path = os.path.join(self.plugins_dir, file)
|
file_path = os.path.join(self.plugins_dir, file)
|
||||||
if os.path.isfile(file_path) and file.endswith(".py"):
|
if os.path.isfile(file_path) and file.endswith(".py"):
|
||||||
try:
|
try:
|
||||||
@ -96,14 +95,14 @@ class PluginsLoader:
|
|||||||
|
|
||||||
ok = True
|
ok = True
|
||||||
try:
|
try:
|
||||||
isfunc = inspect.isfunction
|
is_func = inspect.isfunction
|
||||||
if not isfunc(plugin.load):
|
if not is_func(plugin.load):
|
||||||
self.log.error('Function "def load():" not found.')
|
self.log.error('Function "def load():" not found.')
|
||||||
ok = False
|
ok = False
|
||||||
if not isfunc(plugin.start):
|
if not is_func(plugin.start):
|
||||||
self.log.error('Function "def start():" not found.')
|
self.log.error('Function "def start():" not found.')
|
||||||
ok = False
|
ok = False
|
||||||
if not isfunc(plugin.unload):
|
if not is_func(plugin.unload):
|
||||||
self.log.error('Function "def unload():" not found.')
|
self.log.error('Function "def unload():" not found.')
|
||||||
ok = False
|
ok = False
|
||||||
if type(plugin.kt) != KuiToi:
|
if type(plugin.kt) != KuiToi:
|
||||||
@ -121,22 +120,22 @@ class PluginsLoader:
|
|||||||
f'Plugin name: "{pl_name}"; Plugin file "{file_path}"')
|
f'Plugin name: "{pl_name}"; Plugin file "{file_path}"')
|
||||||
|
|
||||||
plugin.open = plugin.kt.open
|
plugin.open = plugin.kt.open
|
||||||
iscorfunc = inspect.iscoroutinefunction
|
is_coro_func = inspect.iscoroutinefunction
|
||||||
self.plugins.update(
|
self.plugins.update(
|
||||||
{
|
{
|
||||||
pl_name: {
|
pl_name: {
|
||||||
"plugin": plugin,
|
"plugin": plugin,
|
||||||
"load": {
|
"load": {
|
||||||
"func": plugin.load,
|
"func": plugin.load,
|
||||||
"async": iscorfunc(plugin.load)
|
"async": is_coro_func(plugin.load)
|
||||||
},
|
},
|
||||||
"start": {
|
"start": {
|
||||||
"func": plugin.start,
|
"func": plugin.start,
|
||||||
"async": iscorfunc(plugin.start)
|
"async": is_coro_func(plugin.start)
|
||||||
},
|
},
|
||||||
"unload": {
|
"unload": {
|
||||||
"func": plugin.unload,
|
"func": plugin.unload,
|
||||||
"async": iscorfunc(plugin.unload)
|
"async": is_coro_func(plugin.unload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user