📝 add frontmatter config

This commit is contained in:
yanyongyu 2022-01-16 11:30:09 +08:00
parent 9b6d8b6efa
commit 3a9a5a9ce9
15 changed files with 77 additions and 25 deletions

View File

@ -4,6 +4,10 @@
NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及 [`python-dotenv`](https://saurabh-kumar.com/python-dotenv/) 来读取配置
配置项需符合特殊格式或 json 序列化格式详情见 [`pydantic Field Type`](https://pydantic-docs.helpmanual.io/usage/types/) 文档
FrontMatter:
sidebar_position: 1
description: nonebot.config 模块
"""
import os
from pathlib import Path

View File

@ -1,20 +1,27 @@
"""
FrontMatter:
sidebar_position: 9
description: nonebot.consts 模块
"""
from typing_extensions import Literal
# used by Matcher
RECEIVE_KEY = "_receive_{id}"
LAST_RECEIVE_KEY = "_last_receive"
ARG_KEY = "{key}"
REJECT_TARGET = "_current_target"
REJECT_CACHE_TARGET = "_next_target"
RECEIVE_KEY: Literal["_receive_{id}"] = "_receive_{id}"
LAST_RECEIVE_KEY: Literal["_last_receive"] = "_last_receive"
ARG_KEY: Literal["{key}"] = "{key}"
REJECT_TARGET: Literal["_current_target"] = "_current_target"
REJECT_CACHE_TARGET: Literal["_next_target"] = "_next_target"
# used by Rule
PREFIX_KEY = "_prefix"
PREFIX_KEY: Literal["_prefix"] = "_prefix"
CMD_KEY = "command"
RAW_CMD_KEY = "raw_command"
CMD_ARG_KEY = "command_arg"
CMD_KEY: Literal["command"] = "command"
RAW_CMD_KEY: Literal["raw_command"] = "raw_command"
CMD_ARG_KEY: Literal["command_arg"] = "command_arg"
SHELL_ARGS = "_args"
SHELL_ARGV = "_argv"
SHELL_ARGS: Literal["_args"] = "_args"
SHELL_ARGV: Literal["_argv"] = "_argv"
REGEX_MATCHED = "_matched"
REGEX_GROUP = "_matched_groups"
REGEX_DICT = "_matched_dict"
REGEX_MATCHED: Literal["_matched"] = "_matched"
REGEX_GROUP: Literal["_matched_groups"] = "_matched_groups"
REGEX_DICT: Literal["_matched_dict"] = "_matched_dict"

View File

@ -3,6 +3,10 @@
下列文档中的异常是所有 NoneBot 运行时可能会抛出的
这些异常并非所有需要用户处理 NoneBot 内部运行时被捕获并进行对应操作
FrontMatter:
sidebar_position: 10
description: nonebot.exception 模块
"""
from typing import Any, Optional

View File

@ -6,6 +6,10 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
自定义 logger 请参考 [`loguru`][loguru] 文档
[loguru]: https://github.com/Delgan/loguru
FrontMatter:
sidebar_position: 7
description: nonebot.log 模块
"""
import sys
@ -28,9 +32,9 @@ NoneBot 日志记录器对象。
默认信息:
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
- 等级: `INFO` 根据 `config.log_level` 配置改变
- 输出: 输出至 stdout
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
- 等级: `INFO` 根据 `config.log_level` 配置改变
- 输出: 输出至 stdout
用法:
```python

View File

@ -1,7 +1,11 @@
"""
## 事件响应器
该模块实现事件响应器的创建与运行并提供一些快捷方法来帮助用户更好的与机器人进行对话
该模块实现事件响应器的创建与运行并提供一些快捷方法来帮助用户更好的与机器人进行对话
FrontMatter:
sidebar_position: 3
description: nonebot.matcher 模块
"""
from types import ModuleType

View File

@ -2,6 +2,10 @@
## 事件处理
NoneBot 内部处理并按优先级分发事件给所有事件响应器提供了多个插槽以进行事件的预处理等
FrontMatter:
sidebar_position: 2
description: nonebot.message 模块
"""
import asyncio

View File

@ -1,3 +1,9 @@
"""
FrontMatter:
sidebar_position: 4
description: nonebot.params 模块
"""
import asyncio
import inspect
import warnings

View File

@ -3,9 +3,9 @@
每个 `Matcher` 拥有一个 `Permission` 其中是 `PermissionChecker` 的集合只要有一个 `PermissionChecker` 检查结果为 `True` 时就会继续运行
:::tip 提示
`PermissionChecker` 既可以是 async function 也可以是 sync function
:::
FrontMatter:
sidebar_position: 6
description: nonebot.permission 模块
"""
import asyncio

View File

@ -3,9 +3,9 @@
每个事件响应器 `Matcher` 拥有一个匹配规则 `Rule` 其中是 `RuleChecker` 的集合只有当所有 `RuleChecker` 检查结果为 `True` 时继续运行
:::tip 提示
`RuleChecker` 既可以是 async function 也可以是 sync function
:::
FrontMatter:
sidebar_position: 5
description: nonebot.rule 模块
"""
import re

View File

@ -6,6 +6,10 @@
除了 Python 内置的类型下面还出现了如下 NoneBot 自定类型实际上它们是 Python 内置类型的别名
以下类型均可从 nonebot.typing 模块导入
FrontMatter:
sidebar_position: 11
description: nonebot.typing 模块
"""
from typing import (
TYPE_CHECKING,

View File

@ -1,3 +1,9 @@
"""
FrontMatter:
sidebar_position: 8
description: nonebot.utils 模块
"""
import re
import json
import asyncio

View File

@ -0,0 +1,3 @@
{
"position": 15
}

View File

@ -0,0 +1,3 @@
{
"position": 13
}

View File

@ -0,0 +1,3 @@
{
"position": 14
}

View File

@ -1,3 +1,3 @@
{
"position": 20
"position": 12
}