summaryrefslogtreecommitdiff
path: root/ATRI/plugins/manage/modules/debug.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/manage/modules/debug.py')
-rw-r--r--ATRI/plugins/manage/modules/debug.py91
1 files changed, 46 insertions, 45 deletions
diff --git a/ATRI/plugins/manage/modules/debug.py b/ATRI/plugins/manage/modules/debug.py
index 53b75b7..7bd3992 100644
--- a/ATRI/plugins/manage/modules/debug.py
+++ b/ATRI/plugins/manage/modules/debug.py
@@ -11,7 +11,7 @@ from ATRI.utils.ub_paste import paste
from ATRI.exceptions import load_error
-level_list = ['info', 'warning', 'error', 'debug']
+level_list = ["info", "warning", "error", "debug"]
__doc__ = """
@@ -25,44 +25,47 @@ __doc__ = """
get_console = sv.on_command(
cmd="获取log",
- aliases={'获取LOG', '获取控制台', '获取控制台信息'},
+ aliases={"获取LOG", "获取控制台", "获取控制台信息"},
docs=__doc__,
- permission=SUPERUSER
+ permission=SUPERUSER,
)
+
@get_console.handle()
async def _get_console(bot: Bot, event: MessageEvent, state: T_State) -> None:
msg = str(event.message).strip()
if msg:
- state['level'] = msg
+ state["level"] = msg
+
-@get_console.got('level', prompt='需要获取的等级是?')
+@get_console.got("level", prompt="需要获取的等级是?")
async def _got(bot: Bot, event: MessageEvent, state: T_State) -> None:
- quit_list = ['算了', '罢了', '不了']
- if state['level'] in quit_list:
- await get_console.finish('好吧...')
+ quit_list = ["算了", "罢了", "不了"]
+ if state["level"] in quit_list:
+ await get_console.finish("好吧...")
-@get_console.got('line', prompt='需要获取的行数是?')
+
+@get_console.got("line", prompt="需要获取的行数是?")
async def _deal_get(bot: Bot, event: MessageEvent, state: T_State) -> None:
- level = state['level']
- line = state['line']
+ level = state["level"]
+ line = state["line"]
repo = str()
-
+
path = LOGGER_DIR / f"{level}" / f"{NOW_TIME}.log"
- logs = await open_file(path, 'readlines')
-
+ logs = await open_file(path, "readlines")
+
try:
- content = logs[int(line):] # type: ignore
+ content = logs[int(line) :] # type: ignore
repo = "\n".join(content).replace("ATRI", "ATRI")
except IndexError:
- await get_console.finish(f'行数错误...max: {len(logs)}') # type: ignore
-
+ await get_console.finish(f"行数错误...max: {len(logs)}") # type: ignore
+
data = FormData()
- data.add_field('poster', 'ATRI running log')
- data.add_field('syntax', 'text')
- data.add_field('expiration', 'day')
- data.add_field('content', repo)
-
+ data.add_field("poster", "ATRI running log")
+ data.add_field("syntax", "text")
+ data.add_field("expiration", "day")
+ data.add_field("content", repo)
+
msg0 = f"> {event.sender.nickname}\n"
msg0 = msg0 + f"详细请移步此处~\n{await paste(data)}"
await track_error.finish(msg0)
@@ -76,41 +79,39 @@ __doc__ = """
"""
track_error = sv.on_command(
- cmd="track",
- aliases={'追踪'},
- docs=__doc__,
- permission=SUPERUSER
+ cmd="track", aliases={"追踪"}, docs=__doc__, permission=SUPERUSER
)
+
@track_error.args_parser # type: ignore
-async def _track_error_load(bot: Bot,
- event: MessageEvent,
- state: T_State) -> None:
+async def _track_error_load(bot: Bot, event: MessageEvent, state: T_State) -> None:
msg = str(event.message).strip()
- cancel = ['算了', '罢了']
+ cancel = ["算了", "罢了"]
if msg in cancel:
- await track_error.finish('好吧...')
+ await track_error.finish("好吧...")
if not msg:
- await track_error.reject('欸?!要开始debug了吗,请提供追踪ID...Ծ‸Ծ')
+ await track_error.reject("欸?!要开始debug了吗,请提供追踪ID...Ծ‸Ծ")
else:
- state['track'] = msg
+ state["track"] = msg
+
@track_error.handle()
async def _track_error(bot: Bot, event: MessageEvent, state: T_State) -> None:
msg = str(event.message).strip()
if msg:
- state['track'] = msg
+ state["track"] = msg
-@track_error.got('track', prompt='欸?!要开始debug了吗,请提供追踪ID...Ծ‸Ծ')
+
+@track_error.got("track", prompt="欸?!要开始debug了吗,请提供追踪ID...Ծ‸Ծ")
async def _deal_track(bot: Bot, event: MessageEvent, state: T_State) -> None:
- track_id = state['track']
+ track_id = state["track"]
data = dict()
-
+
try:
data = load_error(track_id)
except BaseException:
- await track_error.finish('未发现对应ID呢...(⇀‸↼‶)')
-
+ await track_error.finish("未发现对应ID呢...(⇀‸↼‶)")
+
msg = (
f"ID: [{track_id}]\n"
f"Time: [{data['time']}]\n"
@@ -118,13 +119,13 @@ async def _deal_track(bot: Bot, event: MessageEvent, state: T_State) -> None:
"——————\n"
f"{data['content']}"
)
-
+
data = FormData()
- data.add_field('poster', track_id)
- data.add_field('syntax', 'text')
- data.add_field('expiration', 'day')
- data.add_field('content', msg)
-
+ data.add_field("poster", track_id)
+ data.add_field("syntax", "text")
+ data.add_field("expiration", "day")
+ data.add_field("content", msg)
+
msg0 = f"> {event.sender.nickname}\n"
msg0 = msg0 + f"详细请移步此处~\n{await paste(data)}"
await track_error.finish(msg0)