QChatGPT/pkg/command/entities.py

77 lines
1.6 KiB
Python
Raw Normal View History

2024-01-28 00:16:42 +08:00
from __future__ import annotations
import typing
import pydantic
import mirai
from ..core import app, entities as core_entities
from . import errors, operator
class CommandReturn(pydantic.BaseModel):
2024-03-03 16:34:59 +08:00
"""命令返回值
"""
2024-01-28 00:16:42 +08:00
2024-05-15 21:40:18 +08:00
text: typing.Optional[str] = None
2024-01-28 00:16:42 +08:00
"""文本
"""
2024-05-15 21:40:18 +08:00
image: typing.Optional[mirai.Image] = None
"""弃用"""
image_url: typing.Optional[str] = None
"""图片链接
"""
2024-01-28 00:16:42 +08:00
error: typing.Optional[errors.CommandError]= None
2024-03-22 16:41:46 +08:00
"""错误
"""
2024-01-28 00:16:42 +08:00
class Config:
arbitrary_types_allowed = True
class ExecuteContext(pydantic.BaseModel):
2024-03-03 16:34:59 +08:00
"""单次命令执行上下文
"""
2024-01-28 00:16:42 +08:00
query: core_entities.Query
2024-03-22 16:41:46 +08:00
"""本次消息的请求对象"""
2024-01-28 00:16:42 +08:00
2024-01-29 21:22:27 +08:00
session: core_entities.Session
2024-03-22 16:41:46 +08:00
"""本次消息所属的会话对象"""
2024-01-28 00:16:42 +08:00
command_text: str
2024-03-22 16:41:46 +08:00
"""命令完整文本"""
2024-01-28 00:16:42 +08:00
command: str
2024-03-22 16:41:46 +08:00
"""命令名称"""
2024-01-28 00:16:42 +08:00
crt_command: str
2024-03-22 16:41:46 +08:00
"""当前命令
多级命令中crt_command为当前命令command为根命令
例如!plugin on Webwlkr
处理到plugin时command为plugincrt_command为plugin
处理到on时command为plugincrt_command为on
"""
2024-01-28 00:16:42 +08:00
params: list[str]
2024-03-22 16:41:46 +08:00
"""命令参数
整个命令以空格分割后的参数列表
"""
2024-01-28 00:16:42 +08:00
crt_params: list[str]
2024-03-22 16:41:46 +08:00
"""当前命令参数
多级命令中crt_params为当前命令参数params为根命令参数
例如!plugin on Webwlkr
处理到plugin时params为['on', 'Webwlkr']crt_params为['on', 'Webwlkr']
处理到on时params为['on', 'Webwlkr']crt_params为['Webwlkr']
"""
2024-01-28 00:16:42 +08:00
privilege: int
2024-03-22 16:41:46 +08:00
"""发起人权限"""