Bläddra i källkod

import file with the same name as plugin

master
lanvent 1 år sedan
förälder
incheckning
73de429af1
2 ändrade filer med 7 tillägg och 7 borttagningar
  1. +2
    -2
      plugins/hello/hello.py
  2. +5
    -5
      plugins/plugin_manager.py

plugins/hello/main.py → plugins/hello/hello.py Visa fil

@@ -11,11 +11,11 @@ class Hello(Plugin):
super().__init__()
self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context
# self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context
logger.info("[hello] inited")
logger.info("[Hello] inited")

def on_handle_context(self, e_context: EventContext):

logger.debug("on_handle_context. content: %s" % e_context['context']['content'])
logger.debug("[Hello] on_handle_context. content: %s" % e_context['context']['content'])

if e_context['context']['content'] == "Hello":
e_context['reply']['type'] = "TEXT"

+ 5
- 5
plugins/plugin_manager.py Visa fil

@@ -38,11 +38,11 @@ class PluginManager:
for plugin_name in os.listdir(plugins_dir):
plugin_path = os.path.join(plugins_dir, plugin_name)
if os.path.isdir(plugin_path):
# 判断插件是否包含main.py文件
main_module_path = os.path.join(plugin_path, "main.py")
# 判断插件是否包含同名.py文件
main_module_path = os.path.join(plugin_path, plugin_name+".py")
if os.path.isfile(main_module_path):
# 导入插件的main
import_path = "{}.{}.main".format(plugins_dir, plugin_name)
# 导入插件
import_path = "{}.{}.{}".format(plugins_dir, plugin_name, plugin_name)
main_module = importlib.import_module(import_path)

modified = False
@@ -63,7 +63,7 @@ class PluginManager:

def load_plugins(self):
pconf = self.load_config()
logger.debug("plugins.json config={}" % pconf)
for plugin in pconf["plugins"]:
name = plugin["name"]
enabled = plugin["enabled"]


Laddar…
Avbryt
Spara