Compare commits

...

70 Commits

Author SHA1 Message Date
github-actions[bot]
e5e69c2726 🔖 Release 2.0.0-beta.5 2022-08-04 06:27:40 +00:00
github-actions[bot]
7c7ea613e9 📝 Update changelog 2022-08-04 06:18:34 +00:00
Ju4tCode
bb1b94e5e3 🔖 bump version 2.0.0-beta.5 (#1122) 2022-08-04 14:14:50 +08:00
github-actions[bot]
8420add975 📝 Update changelog 2022-08-04 05:40:36 +00:00
Ju4tCode
2192e8cb6d 🐛 fix parent detect error after require (#1121) 2022-08-04 13:39:20 +08:00
github-actions[bot]
48ccef2f06 📝 Update changelog 2022-08-02 02:31:11 +00:00
AkiraXie
c6bc24efc2 🐛 run_postprecessors handle matcher.state now (#1119) 2022-08-02 10:29:48 +08:00
github-actions[bot]
63f8d78d20 📝 Update changelog 2022-08-01 06:19:28 +00:00
ArgonarioD
db36c262db 🍻 publish plugin 「能不能好好说话?」缩写翻译 (#1117) 2022-08-01 14:18:15 +08:00
github-actions[bot]
732a13b692 📝 Update changelog 2022-08-01 02:53:25 +00:00
Ju4tCode
71bf1d1147 🐛 fix import error if setuptools not installed (#1116)
Fix: 修复 setuptools 未安装导致 ImportError
2022-08-01 10:52:15 +08:00
github-actions[bot]
6e98ac031c 📝 Update changelog 2022-07-31 02:33:58 +00:00
syrinka
9a49354ddd 🍻 publish plugin 推送钩子 (#1114) 2022-07-31 10:32:36 +08:00
github-actions[bot]
455752bd92 📝 Update changelog 2022-07-28 04:42:49 +00:00
yuyuziYYZ
2a51b07229 🍻 publish bot SkadiBot (#1112) 2022-07-28 12:41:42 +08:00
github-actions[bot]
732b5b0b1b 📝 Update changelog 2022-07-25 02:01:16 +00:00
ziru-w
a0dcc7753c 🍻 publish plugin 易命令 (#1110) 2022-07-25 09:59:58 +08:00
github-actions[bot]
12942f2d50 📝 Update changelog 2022-07-23 02:25:34 +00:00
bingqiu456
192d094f54 🍻 publish plugin 群昵称时间 (#1108) 2022-07-23 10:24:17 +08:00
github-actions[bot]
bb02d50837 📝 Update changelog 2022-07-22 06:23:48 +00:00
那个小白白白
bc8c65d0d8 Bot: 修改剑网三 bot 信息 (#1107) 2022-07-22 14:22:36 +08:00
github-actions[bot]
9447b1f462 📝 Update changelog 2022-07-20 02:23:17 +00:00
Dobiichi-Origami
c03b0c73cb Feature: on_x 支持 expire_time 参数 (#1106)
Co-authored-by: Dobiichi-Origami <454470535@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: yanyongyu <42488585+yanyongyu@users.noreply.github.com>
2022-07-20 10:21:31 +08:00
github-actions[bot]
19f4c01ad3 📝 Update changelog 2022-07-15 02:12:35 +00:00
synodriver
9bd07b9ced add block driver startup/shutdown sync support (#1104)
Feature: 正向驱动器 startup/shutdown hook 支持同步函数
2022-07-15 10:11:19 +08:00
github-actions[bot]
fe5cf5624c 📝 Update changelog 2022-07-14 03:31:37 +00:00
Shine-Light
a14c38300e 🍻 publish bot 真宵Bot (#1102) 2022-07-14 11:30:34 +08:00
github-actions[bot]
9e908d5b3f 📝 Update changelog 2022-07-12 07:22:59 +00:00
ziru-w
f1ab95489c 🍻 publish plugin 处理好友添加和群邀请 (#1098) 2022-07-12 15:21:30 +08:00
github-actions[bot]
3c42e26e27 📝 Update changelog 2022-07-12 06:59:52 +00:00
zheuziihau
c248b8c354 🍻 publish plugin 明日方舟寻访记录分析 (#1096) 2022-07-12 14:58:45 +08:00
github-actions[bot]
0ecea50778 📝 Update changelog 2022-07-11 08:05:27 +00:00
ziru-w
33d4d01d51 🍻 publish plugin b站视频每日推送 (#1094) 2022-07-11 16:04:06 +08:00
github-actions[bot]
1667440c64 📝 Update changelog 2022-07-10 06:38:53 +00:00
KarisAya
141527238c 🍻 publish plugin 自动回复(文i)插件 (#1089) 2022-07-10 14:37:54 +08:00
github-actions[bot]
e2d0453741 📝 Update changelog 2022-07-10 02:48:38 +00:00
10-24
0849df1c76 🍻 publish plugin ACC计算工具 (#1092) 2022-07-10 10:47:35 +08:00
github-actions[bot]
c4d45c087a 📝 Update changelog 2022-07-08 04:26:23 +00:00
Ju4tCode
be15cfabcc 📝 Docs: 添加 nonemoji 并更新开发指南 (#1088)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-08 12:24:48 +08:00
github-actions[bot]
dddbeb389f 📝 Update changelog 2022-07-06 03:02:29 +00:00
yaowan233
bdfaf4840f 🍻 publish plugin OSU查分插件 (#1081) 2022-07-06 11:00:35 +08:00
GC-ZF
b37b1380a3 🍻 publish plugin 战地1、5战绩查询工具 (#1086) 2022-07-06 10:59:34 +08:00
github-actions[bot]
d8ed5c2e80 📝 Update changelog 2022-07-06 02:38:40 +00:00
GC-ZF
4bc391c066 🍻 publish plugin 一起燚xN吧 (#1084) 2022-07-06 10:37:18 +08:00
pre-commit-ci[bot]
5aa6138bf3 ⬆️ auto update by pre-commit hooks (#1080)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-05 10:17:39 +08:00
github-actions[bot]
fc78b9c547 📝 Update changelog 2022-07-05 02:17:00 +00:00
Ju4tCode
118874080d ✏️ fix docs event message type error (#1079) 2022-07-05 10:15:55 +08:00
github-actions[bot]
cf2137a1a9 📝 Update changelog 2022-07-02 02:21:11 +00:00
StarHeart
14b145b58d 📝 Docs: 修复旧 Vuepress 文档缓存问题 (#1077)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-02 10:19:51 +08:00
github-actions[bot]
1aba737cbd 📝 Update changelog 2022-07-01 02:58:18 +00:00
Ju4tCode
fe38b1f17f 📝 Docs: 更新 Readme 贡献图片 (#1074) 2022-07-01 10:57:05 +08:00
github-actions[bot]
776651284f 📝 Update changelog 2022-07-01 02:39:14 +00:00
CMHopeSunshine
068cc3a7ea 🍻 publish plugin 米游币商品自动兑换 (#1075) 2022-07-01 10:38:16 +08:00
github-actions[bot]
0e7e88cfa2 📝 Update changelog 2022-06-30 06:31:31 +00:00
StarHeart
c120f9be70 📝 unregister sw loaded from vuepress (#1073) 2022-06-30 14:30:15 +08:00
github-actions[bot]
563436b38e 📝 Update changelog 2022-06-30 06:29:47 +00:00
shinianj
386be6cbb6 🍻 publish plugin 赛马 (#1068) 2022-06-30 14:28:42 +08:00
github-actions[bot]
b5e29533d8 📝 Update changelog 2022-06-30 04:20:11 +00:00
MingxuanGame
beb19adad5 📝 fix docs call Permission wrong (#1072) 2022-06-30 12:19:10 +08:00
github-actions[bot]
e2289c78b0 📝 Update changelog 2022-06-29 02:56:19 +00:00
hamo-reid
d3f261eb34 🍻 publish plugin PicMenu (#1070) 2022-06-29 10:55:16 +08:00
github-actions[bot]
d54c2e6bf4 📝 Update changelog 2022-06-28 02:26:03 +00:00
Mai-icy
6fdebc4912 🍻 publish plugin 面包店小游戏 (#1063) 2022-06-28 10:25:02 +08:00
github-actions[bot]
f1ffac5ca7 📝 Update changelog 2022-06-25 08:20:06 +00:00
A-kirami
12716ee79a 🍻 publish plugin 黑白名单 (#1060) 2022-06-25 16:19:08 +08:00
github-actions[bot]
42413281bb 📝 Update changelog 2022-06-25 04:34:24 +00:00
github-actions[bot]
a67eda4c80 📝 Update changelog 2022-06-24 02:52:05 +00:00
Akirami
9dbea871b8 ✏️ fix type T_RunPostProcessor incorrect description (#1057)
Bug: 修复 typing 中 T_RunPostProcessor 类型的注释描述不正确
2022-06-24 10:51:06 +08:00
github-actions[bot]
4181f4ca77 📝 Update changelog 2022-06-24 02:49:36 +00:00
Special-Week
fe4a33d19b 🍻 publish plugin BitTorrent (#1058) 2022-06-24 10:48:29 +08:00
110 changed files with 1081 additions and 735 deletions

View File

@@ -1,6 +1,6 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/codespaces-linux/.devcontainer/base.Dockerfile
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/codespaces-linux/.devcontainer/base.Dockerfile
FROM mcr.microsoft.com/vscode/devcontainers/universal:linux
FROM mcr.microsoft.com/vscode/devcontainers/universal:2-focal
# ** [Optional] Uncomment this section to install additional packages. **
# USER root
@@ -13,8 +13,3 @@ USER codespace
# [Required] Poetry
RUN curl -sSL https://install.python-poetry.org | python - -y
RUN poetry config virtualenvs.in-project true
# [Required] Gitmoji CLI
# Deprecated: Maybe removed once nonemoji is done
RUN yarn global add gitmoji-cli
ENV PATH="$PATH:/home/codespace/.yarn/bin"

View File

@@ -1,60 +1,87 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/codespaces-linux
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/codespaces-linux
{
"name": "NoneBot",
"name": "GitHub Codespaces (Default)",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
"dockerfile": "Dockerfile"
},
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"python.defaultInterpreterPath": "/opt/python/latest/bin/python",
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.analysis.diagnosticMode": "workspace",
"python.analysis.typeCheckingMode": "basic",
"[python]":{
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"lldb.executable": "/usr/bin/lldb",
"files.exclude": {
"**/__pycache__": true
},
"files.watcherExclude": {
"**/target/**": true,
"**/__pycache__": true
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"python.defaultInterpreterPath": "/opt/python/latest/bin/python",
"python.linting.enabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.analysis.diagnosticMode": "workspace",
"python.analysis.typeCheckingMode": "basic",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"lldb.executable": "/usr/bin/lldb",
"files.exclude": {
"**/__pycache__": true
},
"files.watcherExclude": {
"**/target/**": true,
"**/__pycache__": true
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"GitHub.vscode-pull-request-github",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.isort",
"ms-python.black-formatter",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss"
]
}
},
"remoteUser": "codespace",
"overrideCommand": false,
"mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"],
"mounts": [
"source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"
],
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
@@ -63,21 +90,9 @@
"--init"
],
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"GitHub.vscode-pull-request-github",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.isort",
"ms-python.black-formatter",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// "oryx build" will automatically install your dependencies and attempt to build your project
"postCreateCommand": "poetry install -E all && poetry run pre-commit install && yarn install"
"postCreateCommand": "poetry install && poetry run pre-commit install && yarn install"
}

View File

@@ -35,7 +35,7 @@ jobs:
with:
changelog_file: website/src/pages/changelog.md
latest_changes_position: '# 更新日志\n\n'
latest_changes_title: '## 最近更新'
latest_changes_title: "## 最近更新"
replace_regex: '(?<=## 最近更新\n)[\s\S]*?(?=\n## )'
changelog_body: ${{ steps.release-drafter.outputs.body }}
commit_and_push: false
@@ -49,7 +49,6 @@ jobs:
git diff-index --quiet HEAD || git commit -m ":memo: Update changelog"
git push
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

View File

@@ -1,3 +1,4 @@
default_install_hook_types: [pre-commit, prepare-commit-msg]
ci:
autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks"
autofix_prs: true
@@ -9,14 +10,23 @@ repos:
rev: 5.10.1
hooks:
- id: isort
stages: [commit]
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
stages: [commit]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2
rev: v2.7.1
hooks:
- id: prettier
types_or: [javascript, jsx, ts, tsx, markdown]
types_or: [javascript, jsx, ts, tsx, markdown, yaml]
stages: [commit]
- repo: https://github.com/nonebot/nonemoji
rev: v0.1.2
hooks:
- id: nonemoji
stages: [prepare-commit-msg]

View File

@@ -29,9 +29,6 @@ NoneBot 使用 [poetry](https://python-poetry.org/) 管理项目依赖,由于
poetry install
# 安装 pre-commit git hook
pre-commit install
# 安装 gitmoji git hook
yarn global add gitmoji-cli
gitmoji -i
```
### 使用 GitHub CodespacesDev Container
@@ -44,6 +41,12 @@ gitmoji -i
NoneBot 的 commit message 格式遵循 [gitmoji](https://gitmoji.dev/) 规范,在创建 commit 时请牢记这一点。
或者使用 [nonemoji](https://github.com/nonebot/nonemoji) 代替 git 进行 commitnonemoji 已默认作为项目开发依赖安装。
```bash
nonemoji commit [-e EMOJI] [-m MESSAGE] [-- ...]
```
### 工作流概述
`master` 分支为 NoneBot 的开发分支,在任何情况下都请不要直接修改 `master` 分支,而是创建一个目标分支为 `nonebot:master` 的 Pull Request 来提交修改。Pull Request 标题请尽量更改成中文,以便自动生成更新日志。

View File

@@ -29,20 +29,23 @@ _✨ 跨平台 Python 异步机器人框架 ✨_
<img src="https://github.com/nonebot/nonebot2/actions/workflows/website-deploy.yml/badge.svg?branch=master&event=push" alt="site"/>
</a>
<a href="https://results.pre-commit.ci/latest/github/nonebot/nonebot2/master">
<img src="https://results.pre-commit.ci/badge/github/nonebot/nonebot2/master.svg" />
<img src="https://results.pre-commit.ci/badge/github/nonebot/nonebot2/master.svg" alt="pre-commit" />
</a>
<br />
<a href="https://onebot.dev/">
<img src="https://img.shields.io/badge/OneBot-v11-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="cqhttp">
<img src="https://img.shields.io/badge/OneBot-v11-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="onebot">
</a>
<a href="https://onebot.dev/">
<img src="https://img.shields.io/badge/OneBot-v12-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="onebot">
</a>
<a href="https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p">
<img src="https://img.shields.io/badge/%E9%92%89%E9%92%89-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAnFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4jUzeAAAAM3RSTlMAQKSRaA+/f0YyFevh29R3cyklIfrlyrGsn41tVUs48c/HqJm9uZdhX1otGwkF9IN8V1CX0Q+IAAABY0lEQVRYw+3V2W7CMBAF0JuNQAhhX9OEfYdu9///rUVWpagE27Ef2gfO+0zGozsKnv6bMGzAhkNytIe5gDdzrwtTCwrbI8x4/NF668NAxgI3Q3UtFi3TyPwNQtPLUUmDd8YfqGLNe4v22XwEYb5zoOuF5baHq2UHtsKe5ivWfGAwrWu2mC34QM0PoCAuqZdOmiwV+5BLyMRtZ7dTSEcs48rzWfzwptMLyzpApka1SJ5FtR4kfCqNIBPEVDmqoqgwUYY5plQOlf6UEjNoOPnuKB6wzDyCrks///TDza8+PnR109WQdxLo8RKWq0PPnuXG0OXKQ6wWLFnCg75uYYbhmMIVVdQ709q33aHbGIj6Duz+2k1HQFX9VwqmY8xYsEJll2ahvhWgsjYLHFRXvIi2Qb0jzMQCzC3FAoydxCma88UCzE3JCWwkjCNYyMUCzHX4DiuTMawEwwhW6hnshPhjZzzJfAH0YacpbmRd7QAAAABJRU5ErkJggg==" alt="ding">
<img src="https://img.shields.io/badge/%E9%92%89%E9%92%89-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAnFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4jUzeAAAAM3RSTlMAQKSRaA+/f0YyFevh29R3cyklIfrlyrGsn41tVUs48c/HqJm9uZdhX1otGwkF9IN8V1CX0Q+IAAABY0lEQVRYw+3V2W7CMBAF0JuNQAhhX9OEfYdu9///rUVWpagE27Ef2gfO+0zGozsKnv6bMGzAhkNytIe5gDdzrwtTCwrbI8x4/NF668NAxgI3Q3UtFi3TyPwNQtPLUUmDd8YfqGLNe4v22XwEYb5zoOuF5baHq2UHtsKe5ivWfGAwrWu2mC34QM0PoCAuqZdOmiwV+5BLyMRtZ7dTSEcs48rzWfzwptMLyzpApka1SJ5FtR4kfCqNIBPEVDmqoqgwUYY5plQOlf6UEjNoOPnuKB6wzDyCrks///TDza8+PnR109WQdxLo8RKWq0PPnuXG0OXKQ6wWLFnCg75uYYbhmMIVVdQ709q33aHbGIj6Duz+2k1HQFX9VwqmY8xYsEJll2ahvhWgsjYLHFRXvIi2Qb0jzMQCzC3FAoydxCma88UCzE3JCWwkjCNYyMUCzHX4DiuTMawEwwhW6hnshPhjZzzJfAH0YacpbmRd7QAAAABJRU5ErkJggg==" alt="dingtalk">
</a>
<a href="https://core.telegram.org/bots/api">
<img src="https://img.shields.io/badge/telegram-Bot-lightgrey?style=social&logo=telegram">
<img src="https://img.shields.io/badge/telegram-Bot-lightgrey?style=social&logo=telegram" alt="telegram">
</a>
<a href="https://open.feishu.cn/document/home/index">
<img src="https://img.shields.io/badge/%E9%A3%9E%E4%B9%A6-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAk1BMVEX///8zMzNJSUlSUlJcXFxtbW0zMzNLS0szMzMzMzNBQUGVlZUzMzM1NTU0NDQzMzMzMzM0NDQ0NDQ0NDQ3NzdDQ0M0NDQ2NjY4ODg9PT0zMzM0NDQ5OTk7OzszMzM0NDQ3NzczMzM0NDQ0NDQ0NDQ0NDQ3Nzc2NjY4ODg2NjY7Ozs0NDQ6Ojo6Ojo3Nzc4ODgzMzNGdMWJAAAAMHRSTlMD6h0TDgr8GNf0KQbvhLT45KKTmm4jwHVJLdLFQzbcjFTgzsq7rl58T2kyqD46Y1riMDRhAAAFr0lEQVR42uzZWXKiUACF4YMyqKAQhyjOc7STmLP/1bVlLukESIJ3sLGKbwFU/Q8HuIBKpVKpVCqVSqVSqVQqlUqlUvmNM10Mcfda/U6TPdw3e9lb8ayLO+bPniYu+amjNcPd8U7PFhML0RE5uCvnaY/5SVt0WFvckcu0vxjiYmDxbu5cl2mn9UVHRMa4B2LaP3RYKD1vL6adccRFLSLL/izxxbRz7UXHimdLlFdq2mlvnztYRznZh96cP3G/dkxQRrOnR5c/c5eiQ+S2UTbe/sHir9zD1w6+okz8aXvMItyRqE46ApSHmHYRYdLRoPCMcrAP3TkLC6fpDp5QAn/EtItqij3UG/zgQZH5aWc7ZqJjzA9jKFGf9ppXC3I6uMB/Mzh2mpQQ/Mnp4BSy1Kctx4pFx5qfhA4kqE87pCyrldfBDm6sLqat2mGnttXHDfkvYtryooHo2PCrFm5lcNw1qWr1XUeEm7BH3QYVRJNGcOmoietNmNKDWeKFnCo6b3Wc1drW/NsOLpFRqmmT4xgfPFw42Q7XhkFi2kq2DtKcR2Y8wpTacRdQ3aZYB59ggiOmrS6sFevgDNr9GW6pzRAZdsQsC3rV3x4i6uQha8+sB2h9am9c6rVBDj9ixr5k007rIs+CGV65pl3wXjRi2hrKYjFtM/rI02JaW3XaPYtGtZHHY9qL0lN7QuO2yBMzpenLTvtkZNos+AY1ZcpObtoLtWmrj6TNlCOuJqZ9M3PkaDBlIBHCmwpHyHpjSgMS2ryhcIqsmsWULmR0eTPhK7LsMdMOKHdJM+nw8E+8ZoYDOT3eRDDDuz6HNt7VeszaQtYDJch+38WRZ51TDO+0Y54hylzy0XHib2JI83c0zIoLd1hAeUus1jenQe2HQ79Dg6wB3i1d/uoNpS2JrulgHWqcRxqySjoObrFjfUlLVrVrOtiGMmdCA+ZJx8hlEa9QZ2+oXcNLOkIWEUAHe22sYxqykGdoUV//5w6eoKlkTI3Gdbx7CVmQB10lDWqzSTpemyyoAW28ubYO++oOLqBPbUUtJknHrMnCRihdyaOTdAQsLHSgtSTS2BEHLK4DvQYWFW2lOtiHZi3Fko6fXCjgNVooV0nHl7tMBP1aAaXtJDvYgwGxdMmzLzu1JUyYNSU7IAwiiZ8OJrxKlTzI38QnMORFoqSn8Fh9gikvIa/UVejgDMZMQ9mOOa8WwKCRyysslF6hn2HSwZX4+ew1KGEPCSZKhoqHMw9mLd1rO8aUMYZpexbRV/2AsYBxy7/t3NtuglAQheFR6wEPVEQtaq1WxQNqnfd/urY08QJFYHZS15D9vcHckMzOz/QWA9/3jqHrbmbr1bT10a90ncQcoiclgKY/Vq81q6P2JJqfI+NHPqdDSMRzsEtIXmYGcQcQk2fwKgHxTCIVJGMWwTu6sWGxPSFx+QpkOfz3QcYEJWQhtGsbR5aKCIrHInjXNsSDeITFZ6ELYZEMAnltY8AyawKz4KJAr21IBzkRmB6LOIRGOEhIaHYsciA0uxIshwa/DLQIzrAEy2HswBIBwck9yNOvbWT4YgHEU4zbEiyHsQsXhnmKccmxp2cbxvb8CyDbMBXwD4hsw1BQguUw9s4Mk20YOTFQtmHiDJVtGJhjZRtyEVi2ITbhnLBOMd5qOvqXwz9RFy3bkJpU0LINeTCsJdvIztHVZhsJo77SbOPG6FNltpFQqMxsE7hmS+9ymJxE7XKYUGupyzZS1Kbaso00tbWybONBTadyObyjPlaVbTycRFO28Uh9oyjbEJ/E2JImnVDXy1y6zpHvW5E2npJsI5unI9vIwVe3HKYZaMg2clkoyDby6Wl5mcv0Bp9t5DVEzzZyG4JnG/kdsLONArbQ2UYRlwZwtlHIsoGbbRSdRNtymGbf0LYcpgleQbMNwdUCbcthmrP2j++VjqdSy7Isy7Isy4LxDTcBnqEPd5jdAAAAAElFTkSuQmCC" alt="feishu">
<img src="https://img.shields.io/badge/%E9%A3%9E%E4%B9%A6-Bot-lightgrey?style=social&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNyAyOUMyMSAyOSAyNSAyNi45MzM5IDI4IDIzLjQwNjVDMzYgMTQgNDEuNDI0MiAxNi44MTY2IDQ0IDE3Ljk5OThDMzguNSAyMC45OTk4IDQwLjUgMjkuNjIzMyAzMyAzNS45OTk4QzI4LjM4MiAzOS45MjU5IDIzLjQ5NDUgNDEuMDE0IDE5IDQxQzEyLjUyMzEgNDAuOTc5OSA2Ljg2MjI2IDM3Ljc2MzcgNCAzNS40MDYzVjE2Ljk5OTgiIHN0cm9rZT0iIzMzMyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNNS42NDgwOCAxNS44NjY5QzUuMDIyMzEgMTQuOTU2NyAzLjc3NzE1IDE0LjcyNjEgMi44NjY5NCAxNS4zNTE5QzEuOTU2NzMgMTUuOTc3NyAxLjcyNjE1IDE3LjIyMjggMi4zNTE5MiAxOC4xMzMxTDUuNjQ4MDggMTUuODY2OVpNMzYuMDAyMSAzNS43MzA5QzM2Ljk1OCAzNS4xNzc0IDM3LjI4NDMgMzMuOTUzOSAzNi43MzA5IDMyLjk5NzlDMzYuMTc3NCAzMi4wNDIgMzQuOTUzOSAzMS43MTU3IDMzLjk5NzkgMzIuMjY5MUwzNi4wMDIxIDM1LjczMDlaTTIuMzUxOTIgMTguMTMzMUM1LjI0MzUgMjIuMzM5IDEwLjc5OTIgMjguMTQ0IDE2Ljg4NjUgMzIuMjIzOUMxOS45MzQ1IDM0LjI2NjcgMjMuMjE3IDM1Ljk0NiAyNi40NDkgMzYuNzMyNEMyOS42OTQ2IDM3LjUyMiAzMy4wNDUxIDM3LjQ0MjggMzYuMDAyMSAzNS43MzA5TDMzLjk5NzkgMzIuMjY5MUMzMi4yMDQ5IDMzLjMwNzIgMjkuOTkyOSAzMy40NzggMjcuMzk0NyAzMi44NDU4QzI0Ljc4MyAzMi4yMTAzIDIxLjk0MDUgMzAuNzk1OCAxOS4xMTM1IDI4LjkwMTFDMTMuNDUwOCAyNS4xMDYgOC4yNTY1IDE5LjY2MSA1LjY0ODA4IDE1Ljg2NjlMMi4zNTE5MiAxOC4xMzMxWiIgZmlsbD0iIzMzMyIvPjxwYXRoIGQ9Ik0zMy41OTQ1IDE3QzMyLjgzOTggMTQuNzAyNyAzMC44NTQ5IDkuOTQwNTQgMjcuNTk0NSA3SDExLjU5NDVDMTUuMjE3MSAxMC42NzU3IDIzIDE2IDI3IDI0IiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+" alt="feishu">
</a>
<a href="https://bot.q.qq.com/wiki/">
<img src="https://img.shields.io/badge/QQ%E9%A2%91%E9%81%93-Bot-lightgrey?style=social&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTIuODIgMTMwLjg5Ij48ZyBkYXRhLW5hbWU9IuWbvuWxgiAyIj48ZyBkYXRhLW5hbWU9IuWbvuWxgiAxIj48cGF0aCBkPSJNNTUuNjMgMTMwLjhjLTcgMC0xMy45LjA4LTIwLjg2IDAtMTkuMTUtLjI1LTMxLjcxLTExLjQtMzQuMjItMzAuMy00LjA3LTMwLjY2IDE0LjkzLTU5LjIgNDQuODMtNjYuNjQgMi0uNTEgNS4yMS0uMzEgNS4yMS0xLjYzIDAtMi4xMy4xNC0yLjEzLjE0LTUuNTcgMC0uODktMS4zLTEuNDYtMi4yMi0yLjMxLTYuNzMtNi4yMy03LjY3LTEzLjQxLTEtMjAuMTggNS40LTUuNTIgMTEuODctNS40IDE3LjgtLjU5IDYuNDkgNS4yNiA2LjMxIDEzLjA4LS44NiAyMS0uNjguNzQtMS43OCAxLjYtMS43OCAyLjY3djQuMjFjMCAxLjM1IDIuMiAxLjYyIDQuNzkgMi4zNSAzMS4wOSA4LjY1IDQ4LjE3IDM0LjEzIDQ1IDY2LjM3LTEuNzYgMTguMTUtMTQuNTYgMzAuMjMtMzIuNyAzMC42My04LjAyLjE5LTE2LjA3LS4wMS0yNC4xMy0uMDF6IiBmaWxsPSIjMDI5OWZlIi8+PHBhdGggZD0iTTMxLjQ2IDExOC4zOGMtMTAuNS0uNjktMTYuOC02Ljg2LTE4LjM4LTE3LjI3LTMtMTkuNDIgMi43OC0zNS44NiAxOC40Ni00Ny44MyAxNC4xNi0xMC44IDI5Ljg3LTEyIDQ1LjM4LTMuMTkgMTcuMjUgOS44NCAyNC41OSAyNS44MSAyNCA0NS4yOS0uNDkgMTUuOS04LjQyIDIzLjE0LTI0LjM4IDIzLjUtNi41OS4xNC0xMy4xOSAwLTE5Ljc5IDAiIGZpbGw9IiNmZWZlZmUiLz48cGF0aCBkPSJNNDYuMDUgNzkuNThjLjA5IDUgLjIzIDkuODItNyA5Ljc3LTcuODItLjA2LTYuMS01LjY5LTYuMjQtMTAuMTktLjE1LTQuODItLjczLTEwIDYuNzMtOS44NHM2LjM3IDUuNTUgNi41MSAxMC4yNnoiIGZpbGw9IiMxMDlmZmUiLz48cGF0aCBkPSJNODAuMjcgNzkuMjdjLS41MyAzLjkxIDEuNzUgOS42NC01Ljg4IDEwLTcuNDcuMzctNi44MS00LjgyLTYuNjEtOS41LjItNC4zMi0xLjgzLTEwIDUuNzgtMTAuNDJzNi41OSA0Ljg5IDYuNzEgOS45MnoiIGZpbGw9IiMwODljZmUiLz48L2c+PC9nPjwvc3ZnPg==" alt="QQ频道">
@@ -183,5 +186,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
感谢以下开发者对 NoneBot2 作出的贡献:
<a href="https://github.com/nonebot/nonebot2/graphs/contributors">
<img src="https://contrib.rocks/image?repo=nonebot/nonebot2" />
<img src="https://contrib.rocks/image?repo=nonebot/nonebot2&max=1000" />
</a>

View File

@@ -25,10 +25,10 @@
- `load_from_toml` => {ref}``load_from_toml` <nonebot.plugin.load.load_from_toml>`
- `load_builtin_plugin` => {ref}``load_builtin_plugin` <nonebot.plugin.load.load_builtin_plugin>`
- `load_builtin_plugins` => {ref}``load_builtin_plugins` <nonebot.plugin.load.load_builtin_plugins>`
- `get_plugin` => {ref}``get_plugin` <nonebot.plugin.plugin.get_plugin>`
- `get_plugin_by_module_name` => {ref}``get_plugin_by_module_name` <nonebot.plugin.plugin.get_plugin_by_module_name>`
- `get_loaded_plugins` => {ref}``get_loaded_plugins` <nonebot.plugin.plugin.get_loaded_plugins>`
- `get_available_plugin_names` => {ref}``get_available_plugin_names` <nonebot.plugin.plugin.get_available_plugin_names>`
- `get_plugin` => {ref}``get_plugin` <nonebot.plugin.get_plugin>`
- `get_plugin_by_module_name` => {ref}``get_plugin_by_module_name` <nonebot.plugin.get_plugin_by_module_name>`
- `get_loaded_plugins` => {ref}``get_loaded_plugins` <nonebot.plugin.get_loaded_plugins>`
- `get_available_plugin_names` => {ref}``get_available_plugin_names` <nonebot.plugin.get_available_plugin_names>`
- `export` => {ref}``export` <nonebot.plugin.export.export>`
- `require` => {ref}``require` <nonebot.plugin.load.require>`
@@ -40,8 +40,6 @@ FrontMatter:
import importlib
from typing import Any, Dict, Type, Optional
import pkg_resources
from nonebot.adapters import Bot
from nonebot.utils import escape_tag
from nonebot.config import Env, Config
@@ -49,10 +47,12 @@ from nonebot.log import logger, default_filter
from nonebot.drivers import Driver, ReverseDriver, combine_driver
try:
import pkg_resources
_dist: pkg_resources.Distribution = pkg_resources.get_distribution("nonebot2")
__version__ = _dist.version
VERSION = _dist.parsed_version
except pkg_resources.DistributionNotFound: # pragma: no cover
except Exception: # pragma: no cover
__version__ = None
VERSION = None

View File

@@ -1,15 +1,16 @@
import signal
import asyncio
import threading
from typing import Set, Callable, Awaitable
from typing import Set, Union, Callable, Awaitable
from nonebot.log import logger
from nonebot.drivers import Driver
from nonebot.typing import overrides
from nonebot.config import Env, Config
from nonebot.utils import run_sync, is_coroutine_callable
STARTUP_FUNC = Callable[[], Awaitable[None]]
SHUTDOWN_FUNC = Callable[[], Awaitable[None]]
STARTUP_FUNC = Callable[[], Union[None, Awaitable[None]]]
SHUTDOWN_FUNC = Callable[[], Union[None, Awaitable[None]]]
HANDLED_SIGNALS = (
signal.SIGINT, # Unix signal 2. Sent by Ctrl+C.
signal.SIGTERM, # Unix signal 15. Sent by `kill <pid>`.
@@ -69,7 +70,10 @@ class BlockDriver(Driver):
async def startup(self):
# run startup
cors = [startup() for startup in self.startup_funcs]
cors = [
startup() if is_coroutine_callable(startup) else run_sync(startup)()
for startup in self.startup_funcs
]
if cors:
try:
await asyncio.gather(*cors)
@@ -89,7 +93,10 @@ class BlockDriver(Driver):
logger.info("Waiting for application shutdown.")
# run shutdown
cors = [shutdown() for shutdown in self.shutdown_funcs]
cors = [
shutdown() if is_coroutine_callable(shutdown) else run_sync(shutdown)()
for shutdown in self.shutdown_funcs
]
if cors:
try:
await asyncio.gather(*cors)

View File

@@ -57,7 +57,7 @@ class Config(BaseSettings):
"""开启/关闭冷重载"""
fastapi_reload_dirs: Optional[List[str]] = None
"""重载监控文件夹列表,默认为 uvicorn 默认值"""
fastapi_reload_delay: Optional[float] = None
fastapi_reload_delay: float = 0.25
"""重载延迟,默认为 uvicorn 默认值"""
fastapi_reload_includes: Optional[List[str]] = None
"""要监听的文件列表,支持 glob pattern默认为 uvicorn 默认值"""

View File

@@ -63,7 +63,7 @@ class Config(BaseSettings):
"""开启/关闭冷重载"""
quart_reload_dirs: Optional[List[str]] = None
"""重载监控文件夹列表,默认为 uvicorn 默认值"""
quart_reload_delay: Optional[float] = None
quart_reload_delay: float = 0.25
"""重载延迟,默认为 uvicorn 默认值"""
quart_reload_includes: Optional[List[str]] = None
"""要监听的文件列表,支持 glob pattern默认为 uvicorn 默认值"""

View File

@@ -1,8 +1,8 @@
from types import ModuleType
from datetime import datetime
from contextvars import ContextVar
from collections import defaultdict
from contextlib import AsyncExitStack
from datetime import datetime, timedelta
from typing import (
TYPE_CHECKING,
Any,
@@ -168,7 +168,7 @@ class Matcher(metaclass=MatcherMeta):
*,
plugin: Optional["Plugin"] = None,
module: Optional[ModuleType] = None,
expire_time: Optional[datetime] = None,
expire_time: Optional[Union[datetime, timedelta]] = None,
default_state: Optional[T_State] = None,
default_type_updater: Optional[Union[T_TypeUpdater, Dependent[str]]] = None,
default_permission_updater: Optional[
@@ -216,7 +216,11 @@ class Matcher(metaclass=MatcherMeta):
if handlers
else [],
"temp": temp,
"expire_time": expire_time,
"expire_time": (
expire_time
if isinstance(expire_time, datetime)
else expire_time and datetime.now() + expire_time
),
"priority": priority,
"block": block,
"_default_state": default_state or {},
@@ -682,7 +686,7 @@ class Matcher(metaclass=MatcherMeta):
block=True,
plugin=self.plugin,
module=self.module,
expire_time=datetime.now() + bot.config.session_expire_timeout,
expire_time=bot.config.session_expire_timeout,
default_state=self.state,
default_type_updater=self.__class__._default_type_updater,
default_permission_updater=self.__class__._default_permission_updater,
@@ -701,7 +705,7 @@ class Matcher(metaclass=MatcherMeta):
block=True,
plugin=self.plugin,
module=self.module,
expire_time=datetime.now() + bot.config.session_expire_timeout,
expire_time=bot.config.session_expire_timeout,
default_state=self.state,
default_type_updater=self.__class__._default_type_updater,
default_permission_updater=self.__class__._default_permission_updater,

View File

@@ -208,7 +208,7 @@ async def _run_matcher(
exception=exception,
bot=bot,
event=event,
state=state,
state=matcher.state,
stack=stack,
dependency_cache=dependency_cache,
),

View File

@@ -25,8 +25,6 @@
- `load_from_toml` => {ref}``load_from_toml` <nonebot.plugin.load.load_from_toml>`
- `load_builtin_plugin` => {ref}``load_builtin_plugin` <nonebot.plugin.load.load_builtin_plugin>`
- `load_builtin_plugins` => {ref}``load_builtin_plugins` <nonebot.plugin.load.load_builtin_plugins>`
- `get_plugin` => {ref}``get_plugin` <nonebot.plugin.plugin.get_plugin>`
- `get_loaded_plugins` => {ref}``get_loaded_plugins` <nonebot.plugin.plugin.get_loaded_plugins>`
- `export` => {ref}``export` <nonebot.plugin.export.export>`
- `require` => {ref}``require` <nonebot.plugin.load.require>`
@@ -38,12 +36,12 @@ FrontMatter:
from itertools import chain
from types import ModuleType
from contextvars import ContextVar
from typing import Set, Dict, List, Optional
from typing import Set, Dict, List, Tuple, Optional
_plugins: Dict[str, "Plugin"] = {}
_managers: List["PluginManager"] = []
_current_plugin: ContextVar[Optional["Plugin"]] = ContextVar(
"_current_plugin", default=None
_current_plugin_chain: ContextVar[Tuple["Plugin", ...]] = ContextVar(
"_current_plugin_chain", default=tuple()
)

View File

@@ -9,7 +9,7 @@ FrontMatter:
import warnings
from . import _current_plugin
from . import _current_plugin_chain
class Export(dict):
@@ -58,7 +58,7 @@ def export() -> Export:
"See https://github.com/nonebot/nonebot2/issues/935.",
DeprecationWarning,
)
plugin = _current_plugin.get()
if not plugin:
plugins = _current_plugin_chain.get()
if not plugins:
raise RuntimeError("Export outside of the plugin!")
return plugin.export
return plugins[-1].export

View File

@@ -24,7 +24,7 @@ from . import (
_managers,
_new_plugin,
_revert_plugin,
_current_plugin,
_current_plugin_chain,
_module_name_to_plugin_name,
)
@@ -223,15 +223,15 @@ class PluginLoader(SourceFileLoader):
setattr(module, "__plugin__", plugin)
# detect parent plugin before entering current plugin context
parent_plugin = _current_plugin.get()
if parent_plugin and _managers.index(parent_plugin.manager) < _managers.index(
self.manager
):
plugin.parent_plugin = parent_plugin
parent_plugin.sub_plugins.add(plugin)
parent_plugins = _current_plugin_chain.get()
for pre_plugin in reversed(parent_plugins):
if _managers.index(pre_plugin.manager) < _managers.index(self.manager):
plugin.parent_plugin = pre_plugin
pre_plugin.sub_plugins.add(plugin)
break
# enter plugin context
_plugin_token = _current_plugin.set(plugin)
_plugin_token = _current_plugin_chain.set(parent_plugins + (plugin,))
try:
super().exec_module(module)
@@ -240,7 +240,7 @@ class PluginLoader(SourceFileLoader):
raise
finally:
# leave plugin context
_current_plugin.reset(_plugin_token)
_current_plugin_chain.reset(_plugin_token)
# get plugin metadata
metadata: Optional[PluginMetadata] = getattr(module, "__plugin_meta__", None)

View File

@@ -7,6 +7,7 @@ FrontMatter:
import re
import inspect
from types import ModuleType
from datetime import datetime, timedelta
from typing import Any, Set, Dict, List, Type, Tuple, Union, Optional
from nonebot.matcher import Matcher
@@ -25,14 +26,14 @@ from nonebot.rule import (
shell_command,
)
from .manager import _current_plugin
from .manager import _current_plugin_chain
def _store_matcher(matcher: Type[Matcher]) -> None:
plugin = _current_plugin.get()
plugins = _current_plugin_chain.get()
# only store the matcher defined in the plugin
if plugin:
plugin.matcher.add(matcher)
if plugins:
plugins[-1].matcher.add(matcher)
def _get_matcher_module(depth: int = 1) -> Optional[ModuleType]:
@@ -50,13 +51,13 @@ def on(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = None,
temp: bool = False,
expire_time: Optional[Union[datetime, timedelta]] = None,
priority: int = 1,
block: bool = False,
state: Optional[T_State] = None,
_depth: int = 0,
) -> Type[Matcher]:
"""
注册一个基础事件响应器,可自定义类型。
"""注册一个基础事件响应器,可自定义类型。
参数:
type: 事件响应器类型
@@ -64,19 +65,22 @@ def on(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
plugin_chain = _current_plugin_chain.get()
matcher = Matcher.new(
type,
Rule() & rule,
Permission() | permission,
temp=temp,
expire_time=expire_time,
priority=priority,
block=block,
handlers=handlers,
plugin=_current_plugin.get(),
plugin=plugin_chain[-1] if plugin_chain else None,
module=_get_matcher_module(_depth + 1),
default_state=state,
)
@@ -89,31 +93,34 @@ def on_metaevent(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = None,
temp: bool = False,
expire_time: Optional[Union[datetime, timedelta]] = None,
priority: int = 1,
block: bool = False,
state: Optional[T_State] = None,
_depth: int = 0,
) -> Type[Matcher]:
"""
注册一个元事件响应器。
"""注册一个元事件响应器。
参数:
rule: 事件响应规则
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
plugin_chain = _current_plugin_chain.get()
matcher = Matcher.new(
"meta_event",
Rule() & rule,
Permission(),
temp=temp,
expire_time=expire_time,
priority=priority,
block=block,
handlers=handlers,
plugin=_current_plugin.get(),
plugin=plugin_chain[-1] if plugin_chain else None,
module=_get_matcher_module(_depth + 1),
default_state=state,
)
@@ -127,32 +134,35 @@ def on_message(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = None,
temp: bool = False,
expire_time: Optional[Union[datetime, timedelta]] = None,
priority: int = 1,
block: bool = True,
state: Optional[T_State] = None,
_depth: int = 0,
) -> Type[Matcher]:
"""
注册一个消息事件响应器。
"""注册一个消息事件响应器。
参数:
rule: 事件响应规则
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
plugin_chain = _current_plugin_chain.get()
matcher = Matcher.new(
"message",
Rule() & rule,
Permission() | permission,
temp=temp,
expire_time=expire_time,
priority=priority,
block=block,
handlers=handlers,
plugin=_current_plugin.get(),
plugin=plugin_chain[-1] if plugin_chain else None,
module=_get_matcher_module(_depth + 1),
default_state=state,
)
@@ -165,31 +175,34 @@ def on_notice(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = None,
temp: bool = False,
expire_time: Optional[Union[datetime, timedelta]] = None,
priority: int = 1,
block: bool = False,
state: Optional[T_State] = None,
_depth: int = 0,
) -> Type[Matcher]:
"""
注册一个通知事件响应器。
"""注册一个通知事件响应器。
参数:
rule: 事件响应规则
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
plugin_chain = _current_plugin_chain.get()
matcher = Matcher.new(
"notice",
Rule() & rule,
Permission(),
temp=temp,
expire_time=expire_time,
priority=priority,
block=block,
handlers=handlers,
plugin=_current_plugin.get(),
plugin=plugin_chain[-1] if plugin_chain else None,
module=_get_matcher_module(_depth + 1),
default_state=state,
)
@@ -202,31 +215,34 @@ def on_request(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = None,
temp: bool = False,
expire_time: Optional[Union[datetime, timedelta]] = None,
priority: int = 1,
block: bool = False,
state: Optional[T_State] = None,
_depth: int = 0,
) -> Type[Matcher]:
"""
注册一个请求事件响应器。
"""注册一个请求事件响应器。
参数:
rule: 事件响应规则
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
plugin_chain = _current_plugin_chain.get()
matcher = Matcher.new(
"request",
Rule() & rule,
Permission(),
temp=temp,
expire_time=expire_time,
priority=priority,
block=block,
handlers=handlers,
plugin=_current_plugin.get(),
plugin=plugin_chain[-1] if plugin_chain else None,
module=_get_matcher_module(_depth + 1),
default_state=state,
)
@@ -241,8 +257,7 @@ def on_startswith(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
"""注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
参数:
msg: 指定消息开头内容
@@ -251,6 +266,7 @@ def on_startswith(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -265,8 +281,7 @@ def on_endswith(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
"""注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
参数:
msg: 指定消息结尾内容
@@ -275,6 +290,7 @@ def on_endswith(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -289,8 +305,7 @@ def on_fullmatch(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
"""注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
参数:
msg: 指定消息全匹配内容
@@ -299,6 +314,7 @@ def on_fullmatch(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -312,8 +328,7 @@ def on_keyword(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
"""注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
参数:
keywords: 关键词列表
@@ -321,6 +336,7 @@ def on_keyword(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -335,8 +351,7 @@ def on_command(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息以指定命令开头时响应。
"""注册一个消息事件响应器,并且当消息以指定命令开头时响应。
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`_
@@ -347,6 +362,7 @@ def on_command(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -367,8 +383,7 @@ def on_shell_command(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个支持 `shell_like` 解析参数的命令消息事件响应器。
"""注册一个支持 `shell_like` 解析参数的命令消息事件响应器。
与普通的 `on_command` 不同的是,在添加 `parser` 参数时, 响应器会自动处理消息。
@@ -382,6 +397,7 @@ def on_shell_command(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -402,8 +418,7 @@ def on_regex(
_depth: int = 0,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息匹配正则表达式时响应。
"""注册一个消息事件响应器,并且当消息匹配正则表达式时响应。
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`_
@@ -414,6 +429,7 @@ def on_regex(
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -422,32 +438,42 @@ def on_regex(
class CommandGroup:
"""命令组,用于声明一组有相同名称前缀的命令。"""
"""命令组,用于声明一组有相同名称前缀的命令。
参数:
cmd: 指定命令内容
rule: 事件响应规则
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
def __init__(self, cmd: Union[str, Tuple[str, ...]], **kwargs):
"""
参数:
cmd: 命令前缀
**kwargs: `on_command` 的参数默认值,参考 `on_command <#on-command-cmd-rule-none-aliases-none-kwargs>`_
"""
self.basecmd: Tuple[str, ...] = (cmd,) if isinstance(cmd, str) else cmd
"""
命令前缀
"""
"""命令前缀"""
if "aliases" in kwargs:
del kwargs["aliases"]
self.base_kwargs: Dict[str, Any] = kwargs
"""
其他传递给 `on_command` 的参数默认值
"""
"""其他传递给 `on_command` 的参数默认值"""
def command(self, cmd: Union[str, Tuple[str, ...]], **kwargs) -> Type[Matcher]:
"""
注册一个新的命令。
"""注册一个新的命令。新参数将会覆盖命令组默认值
参数:
cmd: 命令前缀
**kwargs: `on_command` 的参数,将会覆盖命令组默认值
cmd: 指定命令内容
aliases: 命令别名
rule: 事件响应规则
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
sub_cmd = (cmd,) if isinstance(cmd, str) else cmd
cmd = self.basecmd + sub_cmd
@@ -459,12 +485,20 @@ class CommandGroup:
def shell_command(
self, cmd: Union[str, Tuple[str, ...]], **kwargs
) -> Type[Matcher]:
"""
注册一个新的命令。
"""注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
参数:
cmd: 命令前缀
**kwargs: `on_shell_command` 的参数,将会覆盖命令组默认值
cmd: 指定命令内容
rule: 事件响应规则
aliases: 命令别名
parser: `nonebot.rule.ArgumentParser` 对象
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
"""
sub_cmd = (cmd,) if isinstance(cmd, str) else cmd
cmd = self.basecmd + sub_cmd
@@ -478,21 +512,14 @@ class MatcherGroup:
"""事件响应器组合,统一管理。为 `Matcher` 创建提供默认属性。"""
def __init__(self, **kwargs):
"""
创建一个事件响应器组合,参数为默认值,与 `on` 一致
"""
"""创建一个事件响应器组合,参数为默认值,与 `on` 一致"""
self.matchers: List[Type[Matcher]] = []
"""
组内事件响应器列表
"""
"""组内事件响应器列表"""
self.base_kwargs: Dict[str, Any] = kwargs
"""
其他传递给 `on` 的参数默认值
"""
"""其他传递给 `on` 的参数默认值"""
def on(self, **kwargs) -> Type[Matcher]:
"""
注册一个基础事件响应器,可自定义类型。
"""注册一个基础事件响应器,可自定义类型。
参数:
type: 事件响应器类型
@@ -500,6 +527,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -511,13 +539,13 @@ class MatcherGroup:
return matcher
def on_metaevent(self, **kwargs) -> Type[Matcher]:
"""
注册一个元事件响应器。
"""注册一个元事件响应器。
参数:
rule: 事件响应规则
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -531,14 +559,14 @@ class MatcherGroup:
return matcher
def on_message(self, **kwargs) -> Type[Matcher]:
"""
注册一个消息事件响应器。
"""注册一个消息事件响应器。
参数:
rule: 事件响应规则
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -551,13 +579,13 @@ class MatcherGroup:
return matcher
def on_notice(self, **kwargs) -> Type[Matcher]:
"""
注册一个通知事件响应器。
"""注册一个通知事件响应器。
参数:
rule: 事件响应规则
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -570,13 +598,13 @@ class MatcherGroup:
return matcher
def on_request(self, **kwargs) -> Type[Matcher]:
"""
注册一个请求事件响应器。
"""注册一个请求事件响应器。
参数:
rule: 事件响应规则
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -591,8 +619,7 @@ class MatcherGroup:
def on_startswith(
self, msg: Union[str, Tuple[str, ...]], **kwargs
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
"""注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
参数:
msg: 指定消息开头内容
@@ -601,6 +628,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -613,8 +641,7 @@ class MatcherGroup:
return matcher
def on_endswith(self, msg: Union[str, Tuple[str, ...]], **kwargs) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
"""注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
参数:
msg: 指定消息结尾内容
@@ -623,6 +650,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -635,8 +663,7 @@ class MatcherGroup:
return matcher
def on_fullmatch(self, msg: Union[str, Tuple[str, ...]], **kwargs) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
"""注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
参数:
msg: 指定消息全匹配内容
@@ -645,6 +672,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -657,8 +685,7 @@ class MatcherGroup:
return matcher
def on_keyword(self, keywords: Set[str], **kwargs) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
"""注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
参数:
keywords: 关键词列表
@@ -666,6 +693,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -683,8 +711,7 @@ class MatcherGroup:
aliases: Optional[Set[Union[str, Tuple[str, ...]]]] = None,
**kwargs,
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息以指定命令开头时响应。
"""注册一个消息事件响应器,并且当消息以指定命令开头时响应。
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`_
@@ -695,6 +722,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -713,8 +741,7 @@ class MatcherGroup:
parser: Optional[ArgumentParser] = None,
**kwargs,
) -> Type[Matcher]:
"""
注册一个支持 `shell_like` 解析参数的命令消息事件响应器。
"""注册一个支持 `shell_like` 解析参数的命令消息事件响应器。
与普通的 `on_command` 不同的是,在添加 `parser` 参数时, 响应器会自动处理消息。
@@ -728,6 +755,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state
@@ -744,8 +772,7 @@ class MatcherGroup:
def on_regex(
self, pattern: str, flags: Union[int, re.RegexFlag] = 0, **kwargs
) -> Type[Matcher]:
"""
注册一个消息事件响应器,并且当消息匹配正则表达式时响应。
"""注册一个消息事件响应器,并且当消息匹配正则表达式时响应。
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`_
@@ -756,6 +783,7 @@ class MatcherGroup:
permission: 事件响应权限
handlers: 事件处理函数列表
temp: 是否为临时事件响应器(仅执行一次)
expire_time: 事件响应器最终有效时间点,过时即被删除
priority: 事件响应器优先级
block: 是否阻止事件向更低优先级传递
state: 默认 state

View File

@@ -1,4 +1,5 @@
import re
from datetime import datetime, timedelta
from typing import Set, List, Type, Tuple, Union, Optional
from nonebot.matcher import Matcher
@@ -14,6 +15,7 @@ def on(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -23,6 +25,7 @@ def on_metaevent(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -33,6 +36,7 @@ def on_message(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -42,6 +46,7 @@ def on_notice(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -51,6 +56,7 @@ def on_request(
*,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -63,6 +69,7 @@ def on_startswith(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -75,6 +82,7 @@ def on_endswith(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -87,6 +95,7 @@ def on_fullmatch(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -98,6 +107,7 @@ def on_keyword(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -110,6 +120,7 @@ def on_command(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -123,6 +134,7 @@ def on_shell_command(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -135,6 +147,7 @@ def on_regex(
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -149,6 +162,7 @@ class CommandGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -162,6 +176,7 @@ class CommandGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -176,6 +191,7 @@ class CommandGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -190,6 +206,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -202,6 +219,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -212,6 +230,7 @@ class MatcherGroup:
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -223,6 +242,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -233,6 +253,7 @@ class MatcherGroup:
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -243,6 +264,7 @@ class MatcherGroup:
rule: Optional[Union[Rule, T_RuleChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -256,6 +278,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -269,6 +292,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -282,6 +306,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -294,6 +319,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -307,6 +333,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -321,6 +348,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,
@@ -334,6 +362,7 @@ class MatcherGroup:
permission: Optional[Union[Permission, T_PermissionChecker]] = ...,
handlers: Optional[List[Union[T_Handler, Dependent]]] = ...,
temp: bool = ...,
expire_time: Optional[Union[datetime, timedelta]] = ...,
priority: int = ...,
block: bool = ...,
state: Optional[T_State] = ...,

View File

@@ -104,7 +104,7 @@ T_RunPreProcessor = Callable[..., Union[Any, Awaitable[Any]]]
- DefaultParam: 带有默认值的参数
"""
T_RunPostProcessor = Callable[..., Union[Any, Awaitable[Any]]]
"""事件响应器运行前预处理函数 RunPostProcessor 类型
"""事件响应器运行后后处理函数 RunPostProcessor 类型
依赖参数:

644
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot2"
version = "2.0.0-beta.4"
version = "2.0.0-beta.5"
description = "An asynchronous python bot framework."
authors = ["yanyongyu <yyy@nonebot.dev>"]
license = "MIT"
@@ -26,23 +26,24 @@ python = "^3.7.3"
yarl = "^1.7.2"
loguru = "^0.6.0"
pygtrie = "^2.4.1"
fastapi = "^0.78.0"
fastapi = "^0.79.0"
tomlkit = ">=0.10.0,<1.0.0"
typing-extensions = ">=3.10.0,<5.0.0"
Quart = { version = "^0.17.0", optional = true }
websockets = { version="^10.0", optional = true }
pydantic = { version = "~1.9.0", extras = ["dotenv"] }
uvicorn = { version = "^0.17.0", extras = ["standard"] }
uvicorn = { version = "^0.18.0", extras = ["standard"] }
aiohttp = { version = "^3.7.4", extras = ["speedups"], optional = true }
httpx = { version = ">=0.20.0, <1.0.0", extras = ["http2"], optional = true }
[tool.poetry.dev-dependencies]
isort = "^5.10.1"
black = "^22.1.0"
nonemoji = "^0.1.2"
pytest-cov = "^3.0.0"
pre-commit = "^2.16.0"
pytest-xdist = "^2.5.0"
pytest-asyncio = "^0.18.1"
pytest-asyncio = "^0.19.0"
nonebug = { git = "https://github.com/nonebot/nonebug.git" }
nb-autodoc = { git = "https://github.com/nonebot/nb-autodoc.git" }
@@ -53,11 +54,6 @@ aiohttp = ["aiohttp"]
websockets = ["websockets"]
all = ["quart", "aiohttp", "httpx", "websockets"]
# [[tool.poetry.source]]
# name = "aliyun"
# url = "https://mirrors.aliyun.com/pypi/simple/"
# default = true
[tool.pytest.ini_options]
asyncio_mode = "auto"
addopts = "--cov=nonebot --cov-report=term-missing"

View File

@@ -0,0 +1,7 @@
from datetime import datetime, timedelta
from nonebot.matcher import Matcher
test_temp_matcher = Matcher.new("test", temp=True)
test_datetime_matcher = Matcher.new("test", expire_time=datetime.now())
test_timedelta_matcher = Matcher.new("test", expire_time=timedelta(seconds=-1))

View File

@@ -1,6 +1,13 @@
from pathlib import Path
import nonebot
from nonebot.plugin import PluginManager, _managers
_sub_plugins = set()
_sub_plugins |= nonebot.load_plugins(str((Path(__file__).parent / "plugins").resolve()))
manager = PluginManager(
search_path=[str((Path(__file__).parent / "plugins").resolve())]
)
_managers.append(manager)
# test load nested plugin with require
manager.load_plugin("nested_subplugin")
manager.load_plugin("nested_subplugin2")

View File

@@ -0,0 +1 @@
from .nested_subplugin2 import a

View File

@@ -0,0 +1 @@
a = "required by another subplugin"

View File

@@ -157,3 +157,41 @@ async def test_run(app: App):
await test_pause().run(bot, event, {})
assert len(matchers[0]) == 1
assert len(matchers[0][0].handlers) == 0
@pytest.mark.asyncio
async def test_expire(app: App, load_plugin):
from nonebot.matcher import matchers
from nonebot.message import _check_matcher
from plugins.matcher.matcher_expire import (
test_temp_matcher,
test_datetime_matcher,
test_timedelta_matcher,
)
event = make_fake_event(_type="test")()
async with app.test_api() as ctx:
bot = ctx.create_bot()
assert test_temp_matcher in matchers[test_temp_matcher.priority]
await _check_matcher(
test_temp_matcher.priority, test_temp_matcher, bot, event, {}
)
assert test_temp_matcher not in matchers[test_temp_matcher.priority]
event = make_fake_event()()
async with app.test_api() as ctx:
bot = ctx.create_bot()
assert test_datetime_matcher in matchers[test_datetime_matcher.priority]
await _check_matcher(
test_datetime_matcher.priority, test_datetime_matcher, bot, event, {}
)
assert test_datetime_matcher not in matchers[test_datetime_matcher.priority]
event = make_fake_event()()
async with app.test_api() as ctx:
bot = ctx.create_bot()
assert test_timedelta_matcher in matchers[test_timedelta_matcher.priority]
await _check_matcher(
test_timedelta_matcher.priority, test_timedelta_matcher, bot, event, {}
)
assert test_timedelta_matcher not in matchers[test_timedelta_matcher.priority]

View File

@@ -38,6 +38,19 @@ async def test_load_plugin(app: App, load_plugin: Set["Plugin"]):
assert nonebot.load_plugin("some_plugin_not_exist") is None
@pytest.mark.asyncio
async def test_load_nested_plugin(app: App, load_plugin: Set["Plugin"]):
import nonebot
parent_plugin = nonebot.get_plugin("nested")
sub_plugin = nonebot.get_plugin("nested_subplugin")
sub_plugin2 = nonebot.get_plugin("nested_subplugin2")
assert parent_plugin and sub_plugin and sub_plugin2
assert sub_plugin.parent_plugin is parent_plugin
assert sub_plugin2.parent_plugin is parent_plugin
assert parent_plugin.sub_plugins == {sub_plugin, sub_plugin2}
@pytest.mark.asyncio
async def test_bad_plugin(app: App):
import nonebot

View File

@@ -45,16 +45,16 @@ async def _():
```python
from nonebot import on_command
from nonebot.adapters.onebot.v11 import GroupMessageEvent
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent
from nonebot.adapters.onebot.v11 import GROUP_ADMIN, GROUP_OWNER
matcher = on_command("测试权限")
@matcher.handle()
async def _(event: GroupMessageEvent):
if await GROUP_ADMIN(event):
async def _(bot: Bot, event: GroupMessageEvent):
if await GROUP_ADMIN(bot, event):
await matcher.send("管理员测试成功")
elif await GROUP_OWNER(event):
elif await GROUP_OWNER(bot, event):
await matcher.send("群主测试成功")
else:
await matcher.send("群员测试成功")

View File

@@ -168,7 +168,7 @@ async def _(foo: str = EventType()): ...
from nonebot.adapters import Message
from nonebot.params import EventMessage
async def _(foo: str = EventMessage()): ...
async def _(foo: Message = EventMessage()): ...
```
### EventPlainText

View File

@@ -23,8 +23,6 @@ const config = {
},
},
scripts: ["/unregister-sw.js"],
presets: [
[
"docusaurus-preset-nonepress",

View File

@@ -5,6 +5,59 @@ toc_max_heading_level: 2
# 更新日志
## v2.0.0-beta.5
### 🚀 新功能
- Feature: on_x 支持 expire_time 参数 [@Dobiichi-Origami](https://github.com/Dobiichi-Origami) ([#1106](https://github.com/nonebot/nonebot2/pull/1106))
- Feature: 正向驱动器 startup/shutdown hook 支持同步函数 [@synodriver](https://github.com/synodriver) ([#1104](https://github.com/nonebot/nonebot2/pull/1104))
### 🐛 Bug 修复
- Fix: 修复插件父子关系识别错漏 [@yanyongyu](https://github.com/yanyongyu) ([#1121](https://github.com/nonebot/nonebot2/pull/1121))
- Fix: run post hook 应该处理 matcher.state [@AkiraXie](https://github.com/AkiraXie) ([#1119](https://github.com/nonebot/nonebot2/pull/1119))
- Fix: 修复 setuptools 未安装导致 ImportError [@yanyongyu](https://github.com/yanyongyu) ([#1116](https://github.com/nonebot/nonebot2/pull/1116))
- Fix: 修复 typing 中 T_RunPostProcessor 类型的注释描述不正确 [@A-kirami](https://github.com/A-kirami) ([#1057](https://github.com/nonebot/nonebot2/pull/1057))
### 📝 文档
- Docs: 添加 nonemoji 并更新开发指南 [@yanyongyu](https://github.com/yanyongyu) ([#1088](https://github.com/nonebot/nonebot2/pull/1088))
- Docs: 修复 event message 类型注释错误 [@yanyongyu](https://github.com/yanyongyu) ([#1079](https://github.com/nonebot/nonebot2/pull/1079))
- Docs: 修复旧 Vuepress 文档缓存问题 [@StarHeartHunt](https://github.com/StarHeartHunt) ([#1077](https://github.com/nonebot/nonebot2/pull/1077))
- Docs: 更新 Readme 贡献图片 [@yanyongyu](https://github.com/yanyongyu) ([#1074](https://github.com/nonebot/nonebot2/pull/1074))
- Docs: 注销旧 Vuepress 文档的 Service Worker [@StarHeartHunt](https://github.com/StarHeartHunt) ([#1073](https://github.com/nonebot/nonebot2/pull/1073))
- Docs: 修改 `权限控制` 一节中主动调用的错误 [@MingxuanGame](https://github.com/MingxuanGame) ([#1072](https://github.com/nonebot/nonebot2/pull/1072))
### 💫 杂项
- Bot: 修改剑网三 bot 信息 [@JustUndertaker](https://github.com/JustUndertaker) ([#1107](https://github.com/nonebot/nonebot2/pull/1107))
### 🍻 插件发布
- Plugin: 「能不能好好说话?」缩写翻译 [@yanyongyu](https://github.com/yanyongyu) ([#1118](https://github.com/nonebot/nonebot2/pull/1118))
- Plugin: 推送钩子 [@yanyongyu](https://github.com/yanyongyu) ([#1115](https://github.com/nonebot/nonebot2/pull/1115))
- Plugin: 易命令 [@yanyongyu](https://github.com/yanyongyu) ([#1111](https://github.com/nonebot/nonebot2/pull/1111))
- Plugin: 群昵称时间 [@yanyongyu](https://github.com/yanyongyu) ([#1109](https://github.com/nonebot/nonebot2/pull/1109))
- Plugin: 处理好友添加和群邀请 [@yanyongyu](https://github.com/yanyongyu) ([#1099](https://github.com/nonebot/nonebot2/pull/1099))
- Plugin: 明日方舟寻访记录分析 [@yanyongyu](https://github.com/yanyongyu) ([#1097](https://github.com/nonebot/nonebot2/pull/1097))
- Plugin: b 站视频每日推送 [@yanyongyu](https://github.com/yanyongyu) ([#1095](https://github.com/nonebot/nonebot2/pull/1095))
- Plugin: 自动回复(文 i插件 [@yanyongyu](https://github.com/yanyongyu) ([#1090](https://github.com/nonebot/nonebot2/pull/1090))
- Plugin: ACC 计算工具 [@yanyongyu](https://github.com/yanyongyu) ([#1093](https://github.com/nonebot/nonebot2/pull/1093))
- Plugin: OSU 查分插件 [@yanyongyu](https://github.com/yanyongyu) ([#1082](https://github.com/nonebot/nonebot2/pull/1082))
- Plugin: 战地 1、5 战绩查询工具 [@yanyongyu](https://github.com/yanyongyu) ([#1087](https://github.com/nonebot/nonebot2/pull/1087))
- Plugin: 一起燚 xN 吧 [@yanyongyu](https://github.com/yanyongyu) ([#1085](https://github.com/nonebot/nonebot2/pull/1085))
- Plugin: 米游币商品自动兑换 [@yanyongyu](https://github.com/yanyongyu) ([#1076](https://github.com/nonebot/nonebot2/pull/1076))
- Plugin: 赛马 [@yanyongyu](https://github.com/yanyongyu) ([#1069](https://github.com/nonebot/nonebot2/pull/1069))
- Plugin: PicMenu [@yanyongyu](https://github.com/yanyongyu) ([#1071](https://github.com/nonebot/nonebot2/pull/1071))
- Plugin: nonebot-plugin-bread [@yanyongyu](https://github.com/yanyongyu) ([#1064](https://github.com/nonebot/nonebot2/pull/1064))
- Plugin: 黑白名单 [@yanyongyu](https://github.com/yanyongyu) ([#1061](https://github.com/nonebot/nonebot2/pull/1061))
- Plugin: BitTorrent [@yanyongyu](https://github.com/yanyongyu) ([#1059](https://github.com/nonebot/nonebot2/pull/1059))
### 🍻 机器人发布
- Bot: SkadiBot [@yanyongyu](https://github.com/yanyongyu) ([#1113](https://github.com/nonebot/nonebot2/pull/1113))
- Bot: 真宵 Bot [@yanyongyu](https://github.com/yanyongyu) ([#1103](https://github.com/nonebot/nonebot2/pull/1103))
## v2.0.0-beta.4
### 🚀 新功能

View File

@@ -81,10 +81,15 @@
},
{
"name": "剑网三bot",
"desc": "网络游戏《剑三》的群聊机器人数据使用www.jx3api.com",
"desc": "网络游戏《剑侠情缘三》的群聊机器人数据使用www.jx3api.com",
"author": "JustUndertaker",
"homepage": "https://github.com/JustUndertaker/jx3_bot",
"tags": [],
"homepage": "https://github.com/JustUndertaker/mini_jx3_bot",
"tags": [
{
"label": "剑网三",
"color": "#5393ec"
}
],
"is_official": false
},
{
@@ -186,5 +191,47 @@
}
],
"is_official": false
},
{
"name": "真宵Bot",
"desc": "专注群聊的QQ机器人",
"author": "Shine-Light",
"homepage": "https://github.com/Shine-Light/Nonebot_Bot_MayaFey",
"tags": [
{
"label": "QQ",
"color": "#ea5252"
},
{
"label": "娱乐",
"color": "#a46e49"
},
{
"label": "群管",
"color": "#41aecb"
}
],
"is_official": false
},
{
"name": "SkadiBot",
"desc": "明日方舟主题机器人—斯卡蒂",
"author": "yuyuziYYZ",
"homepage": "https://github.com/yuyuziYYZ/skadi_bot",
"tags": [
{
"label": "明日方舟",
"color": "#a48888"
},
{
"label": "斯卡蒂",
"color": "#a48888"
},
{
"label": "arknights",
"color": "#a48888"
}
],
"is_official": false
}
]

View File

@@ -1887,5 +1887,243 @@
"homepage": "https://github.com/AquamarineCyan/nonebot-plugin-today-in-history",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_BitTorrent",
"project_link": "nonebot_plugin_BitTorrent",
"name": "BitTorrent",
"desc": "nonebot2磁力搜索插件",
"author": "Special-Week",
"homepage": "https://github.com/Special-Week/nonebot_plugin_BitTorrent",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_namelist",
"project_link": "nonebot-plugin-namelist",
"name": "黑白名单",
"desc": "简易黑白用户名单管理",
"author": "A-kirami",
"homepage": "https://github.com/A-kirami/nonebot-plugin-namelist",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_bread_shop",
"project_link": "nonebot-plugin-bread-shop",
"name": "面包店小游戏",
"desc": "面包店休闲小游戏",
"author": "Mai-icy",
"homepage": "https://github.com/Mai-icy/nonebot-plugin-bread-shop",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_PicMenu",
"project_link": "nonebot_plugin_PicMenu",
"name": "PicMenu",
"desc": "根据插件元数据生成图片化功能菜单",
"author": "hamo-reid",
"homepage": "https://github.com/hamo-reid/nonenot_plugin_PicMenu",
"tags": [
{
"label": "a:onebot",
"color": "#030303"
},
{
"label": "t:menu",
"color": "#753dc6"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_horserace",
"project_link": "nonebot_plugin_horserace",
"name": "赛马",
"desc": "群内青春版赛马小游戏",
"author": "shinianj",
"homepage": "https://github.com/shinianj/nonebot_plugin_horserace",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_myb_exchange",
"project_link": "nonebot-plugin-myb-exchange",
"name": "米游币商品自动兑换",
"desc": "让Bot帮你抢米游币商品",
"author": "CMHopeSunshine",
"homepage": "https://github.com/CMHopeSunshine/LittlePaimon/tree/Bot/src/plugins/nonebot_plugin_myb_exchange",
"tags": [
{
"label": "a:onebot",
"color": "#000000"
},
{
"label": "t:Genshin",
"color": "#ffca0a"
},
{
"label": "小派蒙",
"color": "#7c0dc3"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_firexN",
"project_link": "nonebot-plugin-firexN",
"name": "一起燚xN吧",
"desc": "QQ续火花可以自定义多个联系人、消息内容、发送时间",
"author": "GC-ZF",
"homepage": "https://github.com/GC-ZF/nonebot_plugin_firexN",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_bfinfo",
"project_link": "nonebot-plugin-bfinfo",
"name": "战地1、5战绩查询工具",
"desc": "QQ私聊或群聊发送战地游戏ID返回基础信息以及最佳兵种、最佳枪械、最佳载具、最佳模式信息",
"author": "GC-ZF",
"homepage": "https://github.com/GC-ZF/nonebot_plugin_bfinfo",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_osubot",
"project_link": "nonebot-plugin-osubot",
"name": "OSU查分插件",
"desc": "OSU查分插件",
"author": "yaowan233",
"homepage": "https://github.com/yaowan233/nonebot-plugin-osubot",
"tags": [
{
"label": "a:onebot",
"color": "#ea5252"
},
{
"label": "OSU",
"color": "#eb5d9b"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_acc_calculate",
"project_link": "nonebot-plugin-acc-calculate",
"name": "ACC计算工具",
"desc": "能够计算段位的单曲acc支持malodyv3段位regular、ex",
"author": "10-24",
"homepage": "https://github.com/10-24/nonebot-plugin-acc-calculate",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_kawaii_robot",
"project_link": "nonebot_plugin_kawaii_robot",
"name": "自动回复文i插件",
"desc": "使用 Kyomotoi/AnimeThesaurus 的nonebot2的回复文i插件",
"author": "KarisAya",
"homepage": "https://github.com/KarisAya/nonebot_plugin_kawaii_robot",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot-plugin-bVideo",
"project_link": "nonebot-plugin-bVideo",
"name": "b站视频每日推送",
"desc": "用于处理推送B站up主最新视频的插件",
"author": "ziru-w",
"homepage": "https://github.com/ziru-w/nonebot_plugin_bVideo",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_arkrecord",
"project_link": "nonebot_plugin_arkrecord",
"name": "明日方舟寻访记录分析",
"desc": "从官网获取明日方舟寻访记录并出图的插件",
"author": "zheuziihau",
"homepage": "https://github.com/zheuziihau/nonebot_plugin_arkrecord",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_addFriend",
"project_link": "nonebot_plugin_addFriend",
"name": "处理好友添加和群邀请",
"desc": "一个基于NoneBot2的插件用于处理被请求加QQ好友和QQ群的请求",
"author": "ziru-w",
"homepage": "https://github.com/ziru-w/nonebot_plugin_addFriend",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_date_name",
"project_link": "nonebot-plugin-date-name",
"name": "群昵称时间",
"desc": "一个可以群昵称显示现在时间的插件",
"author": "bingqiu456",
"homepage": "https://github.com/bingqiu456/nonebot-plugin-date-name",
"tags": [
{
"label": "a:onebot",
"color": "#a552ea"
},
{
"label": "t:qun_card",
"color": "#e552ea"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_easyCommand",
"project_link": "nonebot_plugin_easyCommand",
"name": "易命令",
"desc": "一个基于NoneBot2的简单的用于动态地添加命令或添加定时任务的插件",
"author": "ziru-w",
"homepage": "https://github.com/ziru-w/nonebot_plugin_easyCommand",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_report",
"project_link": "nonebot-plugin-report",
"name": "推送钩子",
"desc": "使用 webhook 向用户推送消息",
"author": "syrinka",
"homepage": "https://github.com/syrinka/nonebot-plugin-report",
"tags": [
{
"label": "t:webhook",
"color": "#51b3a8"
},
{
"label": "t:notify",
"color": "#3985f7"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_hammer_nbnhhsh",
"project_link": "nonebot-plugin-hammer-nbnhhsh",
"name": "「能不能好好说话?」缩写翻译",
"desc": "拼音首字母及阿拉伯数字缩写翻译",
"author": "ArgonarioD",
"homepage": "https://github.com/ArgonarioD/nonebot-plugin-hammer-nbnhhsh",
"tags": [
{
"label": "a:onebot",
"color": "#000000"
},
{
"label": "a:cqhttp",
"color": "#000000"
}
],
"is_official": false
}
]

View File

@@ -0,0 +1,14 @@
self.addEventListener("install", function (e) {
self.skipWaiting();
});
self.addEventListener("activate", function (e) {
self.registration
.unregister()
.then(function () {
return self.clients.matchAll();
})
.then(function (clients) {
clients.forEach((client) => client.navigate(client.url));
});
});

View File

@@ -1,16 +0,0 @@
navigator.serviceWorker.getRegistrations().then(function (e) {
for (
var r, i = e, t = Array.isArray(i), a = 0, i = t ? i : i[Symbol.iterator]();
;
) {
if (t) {
if (a >= i.length) break;
r = i[a++];
} else {
if ((a = i.next()).done) break;
r = a.value;
}
r.unregister();
}
});

View File

@@ -45,16 +45,16 @@ async def _():
```python
from nonebot import on_command
from nonebot.adapters.onebot.v11 import GroupMessageEvent
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent
from nonebot.adapters.onebot.v11 import GROUP_ADMIN, GROUP_OWNER
matcher = on_command("测试权限")
@matcher.handle()
async def _(event: GroupMessageEvent):
if await GROUP_ADMIN(event):
async def _(bot: Bot, event: GroupMessageEvent):
if await GROUP_ADMIN(bot, event):
await matcher.send("管理员测试成功")
elif await GROUP_OWNER(event):
elif await GROUP_OWNER(bot, event):
await matcher.send("群主测试成功")
else:
await matcher.send("群员测试成功")

View File

@@ -11,7 +11,7 @@ description: nonebot.drivers.fastapi 模块
本驱动仅支持服务端连接
:::
## _class_ `Config(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, *, fastapi_openapi_url=None, fastapi_docs_url=None, fastapi_redoc_url=None, fastapi_include_adapter_schema=True, fastapi_reload=False, fastapi_reload_dirs=None, fastapi_reload_delay=None, fastapi_reload_includes=None, fastapi_reload_excludes=None)` {#Config}
## _class_ `Config(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, *, fastapi_openapi_url=None, fastapi_docs_url=None, fastapi_redoc_url=None, fastapi_include_adapter_schema=True, fastapi_reload=False, fastapi_reload_dirs=None, fastapi_reload_delay=0.25, fastapi_reload_includes=None, fastapi_reload_excludes=None)` {#Config}
- **说明**
@@ -83,7 +83,7 @@ description: nonebot.drivers.fastapi 模块
### _class-var_ `fastapi_reload_delay` {#Config-fastapi_reload_delay}
- **类型:** float | None
- **类型:** float
- **说明:** 重载延迟,默认为 uvicorn 默认值

View File

@@ -17,7 +17,7 @@ pip install nonebot2[quart]
本驱动仅支持服务端连接
:::
## _class_ `Config(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, *, quart_reload=False, quart_reload_dirs=None, quart_reload_delay=None, quart_reload_includes=None, quart_reload_excludes=None)` {#Config}
## _class_ `Config(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, *, quart_reload=False, quart_reload_dirs=None, quart_reload_delay=0.25, quart_reload_includes=None, quart_reload_excludes=None)` {#Config}
- **说明**
@@ -57,7 +57,7 @@ pip install nonebot2[quart]
### _class-var_ `quart_reload_delay` {#Config-quart_reload_delay}
- **类型:** float | None
- **类型:** float
- **说明:** 重载延迟,默认为 uvicorn 默认值

View File

@@ -32,10 +32,10 @@ description: nonebot 模块
- `load_from_toml` => [`load_from_toml`](./plugin/load.md#load_from_toml)
- `load_builtin_plugin` => [`load_builtin_plugin`](./plugin/load.md#load_builtin_plugin)
- `load_builtin_plugins` => [`load_builtin_plugins`](./plugin/load.md#load_builtin_plugins)
- `get_plugin` => {ref}``get_plugin` <nonebot.plugin.plugin.get_plugin>`
- `get_plugin_by_module_name` => {ref}``get_plugin_by_module_name` <nonebot.plugin.plugin.get_plugin_by_module_name>`
- `get_loaded_plugins` => {ref}``get_loaded_plugins` <nonebot.plugin.plugin.get_loaded_plugins>`
- `get_available_plugin_names` => {ref}``get_available_plugin_names` <nonebot.plugin.plugin.get_available_plugin_names>`
- `get_plugin` => [`get_plugin`](./plugin/index.md#get_plugin)
- `get_plugin_by_module_name` => [`get_plugin_by_module_name`](./plugin/index.md#get_plugin_by_module_name)
- `get_loaded_plugins` => [`get_loaded_plugins`](./plugin/index.md#get_loaded_plugins)
- `get_available_plugin_names` => [`get_available_plugin_names`](./plugin/index.md#get_available_plugin_names)
- `export` => [`export`](./plugin/export.md#export)
- `require` => [`require`](./plugin/load.md#require)

View File

@@ -205,7 +205,7 @@ description: nonebot.matcher 模块
- `module` (module | None): 事件响应器所在模块
- `expire_time` (datetime.datetime | None): 事件响应器最终有效时间点,过时即被删除
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `default_state` (dict[Any, Any] | None): 默认状态 `state`

View File

@@ -32,8 +32,6 @@ description: nonebot.plugin 模块
- `load_from_toml` => [`load_from_toml`](./load.md#load_from_toml)
- `load_builtin_plugin` => [`load_builtin_plugin`](./load.md#load_builtin_plugin)
- `load_builtin_plugins` => [`load_builtin_plugins`](./load.md#load_builtin_plugins)
- `get_plugin` => {ref}``get_plugin` <nonebot.plugin.plugin.get_plugin>`
- `get_loaded_plugins` => {ref}``get_loaded_plugins` <nonebot.plugin.plugin.get_loaded_plugins>`
- `export` => [`export`](./export.md#export)
- `require` => [`require`](./load.md#require)

View File

@@ -7,7 +7,7 @@ description: nonebot.plugin.on 模块
本模块定义事件响应器便携定义函数。
## _def_ `on(type='', rule=..., permission=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on}
## _def_ `on(type='', rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on}
- **说明**
@@ -25,6 +25,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -35,7 +37,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_metaevent(rule=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_metaevent}
## _def_ `on_metaevent(rule=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_metaevent}
- **说明**
@@ -49,6 +51,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -59,7 +63,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_message}
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_message}
- **说明**
@@ -75,6 +79,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -85,7 +91,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_notice(rule=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_notice}
## _def_ `on_notice(rule=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_notice}
- **说明**
@@ -99,6 +105,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -109,7 +117,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_request(rule=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_request}
## _def_ `on_request(rule=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_request}
- **说明**
@@ -123,6 +131,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -133,7 +143,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_startswith}
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_startswith}
- **说明**
@@ -153,6 +163,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -163,7 +175,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_endswith}
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_endswith}
- **说明**
@@ -183,6 +195,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -193,7 +207,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_fullmatch}
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_fullmatch}
- **说明**
@@ -213,6 +227,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -223,7 +239,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_keyword}
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_keyword}
- **说明**
@@ -241,6 +257,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -251,7 +269,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_command(cmd, rule=..., aliases=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_command}
## _def_ `on_command(cmd, rule=..., aliases=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_command}
- **说明**
@@ -273,6 +291,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -283,7 +303,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_shell_command}
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_shell_command}
- **说明**
@@ -309,6 +329,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -319,7 +341,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_regex}
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on_regex}
- **说明**
@@ -341,6 +363,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -351,7 +375,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
## _class_ `CommandGroup(cmd, *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#CommandGroup}
## _class_ `CommandGroup(cmd, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup}
- **参数**
@@ -365,6 +389,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType)
- `priority` (int)
- `block` (bool)
@@ -383,73 +409,73 @@ description: nonebot.plugin.on 模块
- **说明:** 其他传递给 `on_command` 的参数默认值
### _method_ `command(self, cmd, *, aliases, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#CommandGroup-command}
### _method_ `command(self, cmd, *, aliases, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-command}
- **说明**
注册一个新的命令。
注册一个新的命令。新参数将会覆盖命令组默认值
- **参数**
- `cmd` (str | tuple[str, ...]): 命令前缀
- `cmd` (str | tuple[str, ...]): 指定命令内容
\*\*kwargs: `on_command` 的参数,将会覆盖命令组默认值
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
- `aliases` (set[str | tuple[str, ...]] | None)
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None)
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `temp` (bool)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int)
- `priority` (int): 事件响应器优先级
- `block` (bool)
- `block` (bool): 是否阻止事件向更低优先级传递
- `state` (dict[Any, Any] | None)
- `state` (dict[Any, Any] | None): 默认 state
- **返回**
- Type[nonebot.internal.matcher.Matcher]
### _method_ `shell_command(self, cmd, *, rule=..., aliases, parser=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#CommandGroup-shell_command}
### _method_ `shell_command(self, cmd, *, rule=..., aliases, parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell_command}
- **说明**
注册一个新的命令。
注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
- **参数**
- `cmd` (str | tuple[str, ...]): 命令前缀
- `cmd` (str | tuple[str, ...]): 指定命令内容
\*\*kwargs: `on_shell_command` 的参数,将会覆盖命令组默认值
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
- `aliases` (set[str | tuple[str, ...]] | None)
- `parser` ([ArgumentParser](../rule.md#ArgumentParser) | None): `nonebot.rule.ArgumentParser` 对象
- `parser` ([ArgumentParser](../rule.md#ArgumentParser) | None)
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None)
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `temp` (bool)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int)
- `priority` (int): 事件响应器优先级
- `block` (bool)
- `block` (bool): 是否阻止事件向更低优先级传递
- `state` (dict[Any, Any] | None)
- `state` (dict[Any, Any] | None): 默认 state
- **返回**
- Type[nonebot.internal.matcher.Matcher]
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup}
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup}
- **参数**
@@ -463,6 +489,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType)
- `priority` (int)
- `block` (bool)
@@ -481,7 +509,7 @@ description: nonebot.plugin.on 模块
- **说明:** 其他传递给 `on` 的参数默认值
### _method_ `on(self, *, type=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on}
### _method_ `on(self, *, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on}
- **说明**
@@ -499,6 +527,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -509,7 +539,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_command(self, cmd, aliases=..., *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_command}
### _method_ `on_command(self, cmd, aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_command}
- **说明**
@@ -531,6 +561,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -541,7 +573,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_endswith(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_endswith}
### _method_ `on_endswith(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_endswith}
- **说明**
@@ -561,6 +593,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -571,7 +605,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_fullmatch(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_fullmatch}
### _method_ `on_fullmatch(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_fullmatch}
- **说明**
@@ -591,6 +625,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -601,7 +637,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_keyword(self, keywords, *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_keyword}
### _method_ `on_keyword(self, keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_keyword}
- **说明**
@@ -619,6 +655,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -629,7 +667,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_message(self, *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_message}
### _method_ `on_message(self, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_message}
- **说明**
@@ -645,6 +683,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -655,7 +695,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_metaevent(self, *, rule=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_metaevent}
### _method_ `on_metaevent(self, *, rule=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_metaevent}
- **说明**
@@ -669,6 +709,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -679,7 +721,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_notice(self, *, rule=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_notice}
### _method_ `on_notice(self, *, rule=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_notice}
- **说明**
@@ -693,6 +735,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -703,7 +747,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_regex(self, pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_regex}
### _method_ `on_regex(self, pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_regex}
- **说明**
@@ -725,6 +769,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -735,7 +781,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_request(self, *, rule=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_request}
### _method_ `on_request(self, *, rule=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_request}
- **说明**
@@ -749,6 +795,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -759,7 +807,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_shell_command(self, cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_shell_command}
### _method_ `on_shell_command(self, cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_shell_command}
- **说明**
@@ -785,6 +833,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递
@@ -795,7 +845,7 @@ description: nonebot.plugin.on 模块
- Type[nonebot.internal.matcher.Matcher]
### _method_ `on_startswith(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_startswith}
### _method_ `on_startswith(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on_startswith}
- **说明**
@@ -815,6 +865,8 @@ description: nonebot.plugin.on 模块
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
- `expire_time` (datetime.datetime | datetime.timedelta | NoneType): 事件响应器最终有效时间点,过时即被删除
- `priority` (int): 事件响应器优先级
- `block` (bool): 是否阻止事件向更低优先级传递

View File

@@ -115,7 +115,7 @@ description: nonebot.typing 模块
- **说明**
事件响应器运行前预处理函数 RunPostProcessor 类型
事件响应器运行后后处理函数 RunPostProcessor 类型
依赖参数:

Some files were not shown because too many files have changed in this diff Show More