Difficult-Rocket/Difficult_Rocket/exception/command.py

68 lines
1.5 KiB
Python
Raw Normal View History

2022-06-29 13:45:25 +08:00
# -------------------------------
# Difficult Rocket
2023-01-20 14:08:12 +08:00
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
2022-06-29 13:45:25 +08:00
# All rights reserved
# -------------------------------
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
github: @shenjackyuanjie
gitee: @shenjackyuanjie
"""
from Difficult_Rocket.exception import BaseRuntimeError
__all__ = [
"CommandError",
"CommandParseError",
"CommandQMarkMissing",
"CommandQMarkPosError",
"CommandQMarkConflict",
"CommandQMarkSufMissing",
2023-12-03 16:54:07 +08:00
"CommandQMarkPreMissing",
2022-06-29 13:45:25 +08:00
]
class CommandError(BaseRuntimeError):
"""命令解析相关 error"""
class CommandParseError(CommandError):
"""命令解析时出现错误"""
# QMark -> Quotation marks
# Pos -> Position
2023-12-03 16:54:07 +08:00
2022-06-29 13:45:25 +08:00
class CommandQMarkPosError(CommandParseError):
"""命令中,引号位置不正确
例如 /command "aabcc "awdawd"""
class CommandQMarkMissing(CommandParseError):
"""命令中引号缺失
2023-12-03 16:54:07 +08:00
例如: /command "aawwdawda awdaw"""
2022-06-29 13:45:25 +08:00
class CommandQMarkConflict(CommandParseError):
"""命令中引号位置冲突
例如: /command "aaaa "aaaa aaaa"""
2023-12-03 16:54:07 +08:00
2022-06-29 13:45:25 +08:00
first_qmark_pos = None
conflict_qmark_pos = None
class CommandQMarkPreMissing(CommandQMarkMissing):
"""命令中 前面的引号缺失
例如: /command aaaa" aaaaaa"""
2023-12-03 16:54:07 +08:00
2022-06-29 13:45:25 +08:00
suf_qmark_pos = None
class CommandQMarkSufMissing(CommandQMarkMissing):
"""命令中 后面的引号缺失(引号未闭合)
例如: /command "aaaawaa some command"""
2023-12-03 16:54:07 +08:00
2022-06-29 13:45:25 +08:00
pre_qmark_pos = None