From 987b00d2adbf7b9d0252b55712ddd5e55ac376ff Mon Sep 17 00:00:00 2001 From: snowy Date: Mon, 25 Mar 2024 12:55:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BD=93=E7=A8=8B=E5=BA=8F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=80=80=E5=87=BA=E6=97=B6=E7=BB=99=E8=BD=BB=E9=9B=AA?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=94=99=E8=AF=AF=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_eventpush.py | 1 + liteyuki/utils/liteyuki_api.py | 4 ++-- main.py | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/liteyuki/plugins/liteyuki_eventpush.py b/liteyuki/plugins/liteyuki_eventpush.py index f67e29fe..a01ceaee 100644 --- a/liteyuki/plugins/liteyuki_eventpush.py +++ b/liteyuki/plugins/liteyuki_eventpush.py @@ -1,3 +1,4 @@ +import sys from typing import Optional import nonebot diff --git a/liteyuki/utils/liteyuki_api.py b/liteyuki/utils/liteyuki_api.py index b12bedd5..7b83b054 100644 --- a/liteyuki/utils/liteyuki_api.py +++ b/liteyuki/utils/liteyuki_api.py @@ -7,7 +7,7 @@ import psutil import requests from . import __VERSION_I__, __VERSION__, __NAME__ -from .config import config +from .config import config, load_from_yaml class LiteyukiAPI: @@ -17,7 +17,7 @@ class LiteyukiAPI: with open("data/liteyuki/liteyuki.json", "rb") as f: self.data = json.loads(f.read()) self.liteyuki_id = self.data.get("liteyuki_id") - self.report = config.get("auto_report", True) + self.report = load_from_yaml("config.yml").get("auto_report", True) if self.report: nonebot.logger.info("Auto bug report is enabled") diff --git a/main.py b/main.py index c1798ae6..04420c92 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import nonebot from nonebot.adapters.onebot import v11, v12 from liteyuki.utils.config import config, load_from_yaml from liteyuki.utils import init +from liteyuki.utils.liteyuki_api import liteyuki_api init() nonebot.init(**load_from_yaml("config.yml")) @@ -15,4 +16,8 @@ for adapter in adapters: nonebot.load_plugin("liteyuki.liteyuki_main") if __name__ == "__main__": - nonebot.run() + try: + nonebot.run() + except BaseException as e: + nonebot.logger.error(f"An error occurred: {e}, Bug will be reported automatically.") + liteyuki_api.bug_report(str(e.__repr__()))