mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-26 12:55:06 +08:00
feat: 当程序异常退出时给轻雪提交错误报告
This commit is contained in:
parent
172f45208f
commit
987b00d2ad
@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import nonebot
|
import nonebot
|
||||||
|
@ -7,7 +7,7 @@ import psutil
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from . import __VERSION_I__, __VERSION__, __NAME__
|
from . import __VERSION_I__, __VERSION__, __NAME__
|
||||||
from .config import config
|
from .config import config, load_from_yaml
|
||||||
|
|
||||||
|
|
||||||
class LiteyukiAPI:
|
class LiteyukiAPI:
|
||||||
@ -17,7 +17,7 @@ class LiteyukiAPI:
|
|||||||
with open("data/liteyuki/liteyuki.json", "rb") as f:
|
with open("data/liteyuki/liteyuki.json", "rb") as f:
|
||||||
self.data = json.loads(f.read())
|
self.data = json.loads(f.read())
|
||||||
self.liteyuki_id = self.data.get("liteyuki_id")
|
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:
|
if self.report:
|
||||||
nonebot.logger.info("Auto bug report is enabled")
|
nonebot.logger.info("Auto bug report is enabled")
|
||||||
|
|
||||||
|
5
main.py
5
main.py
@ -2,6 +2,7 @@ import nonebot
|
|||||||
from nonebot.adapters.onebot import v11, v12
|
from nonebot.adapters.onebot import v11, v12
|
||||||
from liteyuki.utils.config import config, load_from_yaml
|
from liteyuki.utils.config import config, load_from_yaml
|
||||||
from liteyuki.utils import init
|
from liteyuki.utils import init
|
||||||
|
from liteyuki.utils.liteyuki_api import liteyuki_api
|
||||||
|
|
||||||
init()
|
init()
|
||||||
nonebot.init(**load_from_yaml("config.yml"))
|
nonebot.init(**load_from_yaml("config.yml"))
|
||||||
@ -15,4 +16,8 @@ for adapter in adapters:
|
|||||||
nonebot.load_plugin("liteyuki.liteyuki_main")
|
nonebot.load_plugin("liteyuki.liteyuki_main")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
nonebot.run()
|
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__()))
|
||||||
|
Loading…
Reference in New Issue
Block a user