diff --git a/pkg/qqbot/process.py b/pkg/qqbot/process.py index 16a4ced9..afbdba6c 100644 --- a/pkg/qqbot/process.py +++ b/pkg/qqbot/process.py @@ -14,6 +14,8 @@ import config import pkg.openai.session import pkg.openai.manager +import pkg.utils.reloader +import pkg.utils.updater processing = [] @@ -157,6 +159,21 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes if not (hasattr(config, 'include_image_description') and not config.include_image_description): reply.append(" ".join(params)) + elif cmd == 'reload' and launcher_type == 'person' and launcher_id == config.admin_qq: + try: + pkg.utils.reloader.reload_all() + reply = ["[bot]已重新加载所有模块"] + except Exception as e: + logging.error("reload failed:{}".format(e)) + reply = ["[bot]重载失败:{}".format(e)] + elif cmd == 'update' and launcher_type == 'person' and launcher_id == config.admin_qq: + try: + pkg.utils.updater.update_all() + pkg.utils.reloader.reload_all() + reply = ["[bot]已更新所有模块"] + except Exception as e: + logging.error("update failed:{}".format(e)) + reply = ["[bot]更新失败:{}".format(e)] except Exception as e: mgr.notify_admin("{}指令执行失败:{}".format(session_name, e)) logging.exception(e)