mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-02-13 02:49:08 +08:00
import file with the same name as plugin
This commit is contained in:
@@ -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"
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user