You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
896B

  1. import os
  2. import json
  3. from config import pconf
  4. from common.log import logger
  5. class Plugin:
  6. def __init__(self):
  7. self.handlers = {}
  8. def load_config(self) -> dict:
  9. """
  10. 加载当前插件配置
  11. :return: 插件配置字典
  12. """
  13. # 优先获取 plugins/config.json 中的全局配置
  14. plugin_conf = pconf(self.name)
  15. if not plugin_conf:
  16. # 全局配置不存在,则获取插件目录下的配置
  17. plugin_config_path = os.path.join(self.path, "config.json")
  18. if os.path.exists(plugin_config_path):
  19. with open(plugin_config_path, "r") as f:
  20. plugin_conf = json.load(f)
  21. logger.debug(f"loading plugin config, plugin_name={self.name}, conf={plugin_conf}")
  22. return plugin_conf
  23. def get_help_text(self, **kwargs):
  24. return "暂无帮助信息"