diff --git a/pkg/qqbot/process.py b/pkg/qqbot/process.py index 9a00d84d..40234449 100644 --- a/pkg/qqbot/process.py +++ b/pkg/qqbot/process.py @@ -252,12 +252,14 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes elif cmd == 'update' and launcher_type == 'person' and launcher_id == config.admin_qq: def update_task(): try: - pkg.utils.updater.update_all() + if pkg.utils.updater.update_all(): + pkg.utils.reloader.reload_all(notify=False) + pkg.utils.context.get_qqbot_manager().notify_admin("更新完成") + else: + pkg.utils.context.get_qqbot_manager().notify_admin("无新版本") except Exception as e0: pkg.utils.context.get_qqbot_manager().notify_admin("更新失败:{}".format(e0)) return - pkg.utils.reloader.reload_all(notify=False) - pkg.utils.context.get_qqbot_manager().notify_admin("更新完成") threading.Thread(target=update_task, daemon=True).start() diff --git a/pkg/utils/updater.py b/pkg/utils/updater.py index 79c5bd6b..8b832eba 100644 --- a/pkg/utils/updater.py +++ b/pkg/utils/updater.py @@ -3,7 +3,7 @@ import datetime import pkg.utils.context -def update_all(): +def update_all() -> bool: """使用dulwich更新源码""" try: import dulwich @@ -14,7 +14,6 @@ def update_all(): from dulwich import porcelain repo = porcelain.open_repo('.') porcelain.pull(repo) - after_commit_id = get_current_commit_id() change_log = "" @@ -27,6 +26,9 @@ def update_all(): if change_log != "": pkg.utils.context.get_qqbot_manager().notify_admin("代码拉取完成,更新内容如下:\n"+change_log) + return True + else: + return False except ModuleNotFoundError: raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77") except dulwich.porcelain.DivergedBranches: