mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
feat: 支持指令操作热更新和热重载
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user