mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-10-06 18:56:45 +00:00
Compare commits
73 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c9c50fa0eb | ||
|
9dcb734547 | ||
|
577d27ef5f | ||
|
a6687dc887 | ||
|
a27e9b078c | ||
|
d75d29b954 | ||
|
6ad289274f | ||
|
7d87244b3e | ||
|
fd0ca2d883 | ||
|
45c96cad1a | ||
|
8d4822ed21 | ||
|
e5194c715b | ||
|
f532573458 | ||
|
c9c8e4d106 | ||
|
58f3325b2c | ||
|
456f923cd2 | ||
|
66d70b5675 | ||
|
c7e57a070a | ||
|
948f96d0f2 | ||
|
d67238194f | ||
|
3c53260f07 | ||
|
581ba52fcb | ||
|
f7d385be93 | ||
|
f4a31a6404 | ||
|
e7f0a2466a | ||
|
d228c3665c | ||
|
fc6aca5394 | ||
|
8f62306086 | ||
|
10048d401a | ||
|
3043b1e2f2 | ||
|
debdb55955 | ||
|
da7e914c74 | ||
|
e854d0ddf8 | ||
|
04465ea688 | ||
|
24c862843a | ||
|
c85b4bcee3 | ||
|
34c99bd2c0 | ||
|
ddc99eedda | ||
|
4c71b8a2a0 | ||
|
7cb39acab6 | ||
|
933a105348 | ||
|
b52905b8ee | ||
|
9e9c1a27e5 | ||
|
e2463e9e39 | ||
|
9681c92bfc | ||
|
def8c34918 | ||
|
6dc52c9d6b | ||
|
a22b8213ef | ||
|
e2901debfb | ||
|
7e16b034b8 | ||
|
a30bfb76ff | ||
|
9d6ca5c7eb | ||
|
2ac102ea53 | ||
|
9fe86f61d6 | ||
|
47be1aea18 | ||
|
180de00d0b | ||
|
fbec37d089 | ||
|
9b83cf4945 | ||
|
790461d8b7 | ||
|
22b848dfcc | ||
|
9915e89ceb | ||
|
3adc2cc761 | ||
|
38d8701d45 | ||
|
6633d4d2c9 | ||
|
1864269be5 | ||
|
df5b21cb9f | ||
|
460fb59322 | ||
|
0b63ff6e73 | ||
|
d1b9dad8f4 | ||
|
42e4206916 | ||
|
384f99eae6 | ||
|
152af6b458 | ||
|
e9bf5d6931 |
6
.github/actions/setup-node/action.yml
vendored
6
.github/actions/setup-node/action.yml
vendored
@@ -4,10 +4,10 @@ description: Setup Node
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: "18"
|
||||
cache: "yarn"
|
||||
node-version: lts/*
|
||||
cache: yarn
|
||||
|
||||
- run: yarn install --frozen-lockfile
|
||||
shell: bash
|
||||
|
4
.github/workflows/codecov.yml
vendored
4
.github/workflows/codecov.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
||||
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
env: [pydantic-v1, pydantic-v2]
|
||||
env:
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
PYDANTIC_VERSION: ${{ matrix.env }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
2
.github/workflows/noneflow.yml
vendored
2
.github/workflows/noneflow.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
private_key: ${{ secrets.APP_KEY }}
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
|
2
.github/workflows/pyright.yml
vendored
2
.github/workflows/pyright.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
4
.github/workflows/release-drafter.yml
vendored
4
.github/workflows/release-drafter.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.APP_KEY }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.APP_KEY }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Python Environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.APP_KEY }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
|
2
.github/workflows/ruff.yml
vendored
2
.github/workflows/ruff.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Run Ruff Lint
|
||||
uses: astral-sh/ruff-action@v3
|
||||
|
2
.github/workflows/website-deploy.yml
vendored
2
.github/workflows/website-deploy.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
4
.github/workflows/website-preview-cd.yml
vendored
4
.github/workflows/website-preview-cd.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Set Commit Status
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
github.rest.repos.createCommitStatus({
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
:rocket: Deployed to ${{ steps.deploy.outputs.deploy-url }}
|
||||
|
||||
- name: Set Commit Status
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v8
|
||||
if: always()
|
||||
with:
|
||||
script: |
|
||||
|
2
.github/workflows/website-preview-ci.yml
vendored
2
.github/workflows/website-preview-ci.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
|
@@ -7,7 +7,7 @@ ci:
|
||||
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.12.7
|
||||
rev: v0.12.11
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
args: [--fix]
|
||||
|
@@ -1 +1,2 @@
|
||||
.github/**/*.md
|
||||
website/docs/tutorial/application.mdx
|
||||
|
@@ -129,7 +129,6 @@ NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架
|
||||
| 开黑啦([仓库](https://github.com/Tian-que/nonebot-adapter-kaiheila),[协议](https://developer.kookapp.cn/)) | ↗️ | 由社区贡献 |
|
||||
| Ntchat([仓库](https://github.com/JustUndertaker/adapter-ntchat)) | ↗️ | 微信协议,由社区贡献 |
|
||||
| MineCraft([仓库](https://github.com/17TheWord/nonebot-adapter-minecraft)) | ↗️ | 由社区贡献 |
|
||||
| BiliBili Live([仓库](https://github.com/wwweww/adapter-bilibili)) | ↗️ | 由社区贡献 |
|
||||
| Walle-Q([仓库](https://github.com/onebot-walle/nonebot_adapter_walleq)) | ↗️ | QQ 协议,由社区贡献 |
|
||||
| Villa([仓库](https://github.com/CMHopeSunshine/nonebot-adapter-villa)) | ❌ | 米游社大别野 Bot 协议,官方已下线 |
|
||||
| Rocket.Chat([仓库](https://github.com/IUnlimit/nonebot-adapter-rocketchat),[协议](https://developer.rocket.chat/)) | ↗️ | Rocket.Chat Bot 协议,由社区贡献 |
|
||||
@@ -139,6 +138,8 @@ NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架
|
||||
| 微信公众平台([仓库](https://github.com/YangRucheng/nonebot-adapter-wxmp),[协议](https://developers.weixin.qq.com/doc/))| ↗️ | 微信公众平台协议,由社区贡献 |
|
||||
| Gewechat([仓库](https://github.com/Shine-Light/nonebot-adapter-gewechat),[协议](https://github.com/Devo919/Gewechat))| ❌ | Gewechat 微信协议,Gewechat不再维护及可用 |
|
||||
| EFChat([仓库](https://github.com/molanp/nonebot_adapter_efchat),[协议](https://irinu-live.melon.fish/efc-help/)) | ↗️ | 恒五聊平台协议,由社区贡献 |
|
||||
| VoceChat ([仓库](https://github.com/5656565566/nonebot-adapter-vocechat),[协议](https://doc.voce.chat/zh-cn/bot/bot-and-webhook)) | ↗️ | VoceChat 平台协议,由社区贡献 |
|
||||
| B站直播间([仓库](https://github.com/MingxuanGame/nonebot-adapter-bilibili-live),[Web API 协议](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/live),[开放平台协议](https://open-live.bilibili.com/document)) | ↗️ | B站直播间(Web API/开放平台)协议,由社区贡献 |
|
||||
|
||||
- 坚实后盾:支持多种 web 框架,可自定义替换、组合
|
||||
|
||||
|
@@ -313,4 +313,29 @@
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot.adapters.vocechat",
|
||||
"project_link": "nonebot-adapter-vocechat",
|
||||
"name": "nonebot-adapter-vocechat",
|
||||
"desc": "Vocechat 协议适配器",
|
||||
"author_id": 56059687,
|
||||
"homepage": "https://github.com/5656565566/nonebot-adapter-vocechat",
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot.adapters.bilibili_live",
|
||||
"project_link": "nonebot-adapter-bilibili-live",
|
||||
"name": "B站直播间",
|
||||
"desc": "B 站直播间协议(Web API/开放平台)支持",
|
||||
"author_id": 68982190,
|
||||
"homepage": "https://github.com/MingxuanGame/nonebot-adapter-bilibili-live",
|
||||
"tags": [
|
||||
{
|
||||
"label": "bilibili",
|
||||
"color": "#ff6699"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
]
|
||||
|
@@ -743,4 +743,25 @@
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"name": "Amrita",
|
||||
"desc": "LLM聊天机器人框架",
|
||||
"author_id": 67693593,
|
||||
"homepage": "https://github.com/LiteSuggarDEV/Amrita",
|
||||
"tags": [
|
||||
{
|
||||
"label": "聊天",
|
||||
"color": "#ea5252"
|
||||
},
|
||||
{
|
||||
"label": "LLM",
|
||||
"color": "#5c86db"
|
||||
},
|
||||
{
|
||||
"label": "快捷部署",
|
||||
"color": "#eebe0b"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
]
|
||||
|
@@ -5148,13 +5148,6 @@
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_cnrail",
|
||||
"project_link": "nonebot-plugin-cnrail",
|
||||
"author_id": 59048777,
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_longtu",
|
||||
"project_link": "nonebot-plugin-longtu",
|
||||
@@ -5251,13 +5244,6 @@
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_pingti",
|
||||
"project_link": "nonebot-plugin-pingti",
|
||||
"author_id": 59048777,
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_wx4",
|
||||
"project_link": "nonebot-plugin-wx4",
|
||||
@@ -9444,4 +9430,338 @@
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_value",
|
||||
"project_link": "nonebot-plugin-value",
|
||||
"author_id": 67693593,
|
||||
"tags": [
|
||||
{
|
||||
"label": "value",
|
||||
"color": "#d10a0a"
|
||||
},
|
||||
{
|
||||
"label": "货币",
|
||||
"color": "#3c0eff"
|
||||
},
|
||||
{
|
||||
"label": "经济",
|
||||
"color": "#1b9f1d"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_mcplayer_render",
|
||||
"project_link": "nonebot-plugin-mcplayer-render",
|
||||
"author_id": 49135577,
|
||||
"tags": [
|
||||
{
|
||||
"label": "Minecraft",
|
||||
"color": "#ea5252"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_alisten",
|
||||
"project_link": "nonebot-plugin-alisten",
|
||||
"author_id": 5219550,
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_simple_setu",
|
||||
"project_link": "nonebot-plugin-simple-setu",
|
||||
"author_id": 178264759,
|
||||
"tags": [
|
||||
{
|
||||
"label": "pixiv",
|
||||
"color": "#00f5ed"
|
||||
},
|
||||
{
|
||||
"label": "色图",
|
||||
"color": "#ed0823"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot-plugin-anipusher",
|
||||
"project_link": "nonebot-plugin-anipusher",
|
||||
"author_id": 32594985,
|
||||
"tags": [
|
||||
{
|
||||
"label": "Emby",
|
||||
"color": "#0b8a31"
|
||||
},
|
||||
{
|
||||
"label": "AniRss",
|
||||
"color": "#0b8a31"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_huaer_bot",
|
||||
"project_link": "nonebot-plugin-huaer-bot",
|
||||
"author_id": 216365707,
|
||||
"tags": [
|
||||
{
|
||||
"label": "LLM",
|
||||
"color": "#0583b3"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_sell_poor",
|
||||
"project_link": "nonebot-plugin-sell-poor",
|
||||
"author_id": 96647974,
|
||||
"tags": [
|
||||
{
|
||||
"label": "卖弱",
|
||||
"color": "#ea5252"
|
||||
},
|
||||
{
|
||||
"label": "😭😭😭",
|
||||
"color": "#52eaba"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_abs",
|
||||
"project_link": "nonebot-plugin-abs",
|
||||
"author_id": 64878354,
|
||||
"tags": [
|
||||
{
|
||||
"label": "abstract",
|
||||
"color": "#edf119"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_ImageLibrary",
|
||||
"project_link": "nonebot-plugin-imagelibrary",
|
||||
"author_id": 126797731,
|
||||
"tags": [
|
||||
{
|
||||
"label": "image",
|
||||
"color": "#7629c4"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_exhibitionism",
|
||||
"project_link": "nonebot_plugin_exhibitionism",
|
||||
"author_id": 78413699,
|
||||
"tags": [],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_akashgen",
|
||||
"project_link": "nonebot-plugin-akashgen",
|
||||
"author_id": 144674902,
|
||||
"tags": [
|
||||
{
|
||||
"label": "绘画",
|
||||
"color": "#98f698"
|
||||
},
|
||||
{
|
||||
"label": "Akash",
|
||||
"color": "#a1eecf"
|
||||
},
|
||||
{
|
||||
"label": "AI",
|
||||
"color": "#78bbf0"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_figurine",
|
||||
"project_link": "nonebot-plugin-figurine",
|
||||
"author_id": 99017826,
|
||||
"tags": [
|
||||
{
|
||||
"label": "figurine",
|
||||
"color": "#ea5252"
|
||||
},
|
||||
{
|
||||
"label": "手办",
|
||||
"color": "#ea5252"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_distributed_blacklist",
|
||||
"project_link": "nonebot-plugin-distributed-blacklist",
|
||||
"author_id": 65720409,
|
||||
"tags": [
|
||||
{
|
||||
"label": "blacklist",
|
||||
"color": "#000000"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_bafortune",
|
||||
"project_link": "nonebot-plugin-bafortune",
|
||||
"author_id": 98072207,
|
||||
"tags": [
|
||||
{
|
||||
"label": "碧蓝档案",
|
||||
"color": "#2b8dce"
|
||||
},
|
||||
{
|
||||
"label": "今日运势",
|
||||
"color": "#ce2b2b"
|
||||
},
|
||||
{
|
||||
"label": "多平台适配",
|
||||
"color": "#c2ce2b"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_repeat_checker",
|
||||
"project_link": "nonebot-plugin-repeat-checker",
|
||||
"author_id": 56631400,
|
||||
"tags": [
|
||||
{
|
||||
"label": "复读",
|
||||
"color": "#ea5252"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_quark_autosave",
|
||||
"project_link": "nonebot-plugin-quark-autosave",
|
||||
"author_id": 64878354,
|
||||
"tags": [
|
||||
{
|
||||
"label": "quark",
|
||||
"color": "#593dc3"
|
||||
},
|
||||
{
|
||||
"label": "夸克",
|
||||
"color": "#6542eb"
|
||||
},
|
||||
{
|
||||
"label": "网盘",
|
||||
"color": "#235c84"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_who_is_spy",
|
||||
"project_link": "nonebot-plugin-who-is-spy",
|
||||
"author_id": 144591143,
|
||||
"tags": [
|
||||
{
|
||||
"label": "game",
|
||||
"color": "#ea5252"
|
||||
},
|
||||
{
|
||||
"label": "游戏",
|
||||
"color": "#ea52cd"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_dst_qq",
|
||||
"project_link": "nonebot-plugin-dst-qq",
|
||||
"author_id": 145603392,
|
||||
"tags": [
|
||||
{
|
||||
"label": "server",
|
||||
"color": "#52ea9d"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_fupan",
|
||||
"project_link": "nonebot-plugin-fupan",
|
||||
"author_id": 867749,
|
||||
"tags": [
|
||||
{
|
||||
"label": "股票",
|
||||
"color": "#ea5252"
|
||||
},
|
||||
{
|
||||
"label": "打卡",
|
||||
"color": "#ea5252"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_algo",
|
||||
"project_link": "nonebot-plugin-algo",
|
||||
"author_id": 188494207,
|
||||
"tags": [
|
||||
{
|
||||
"label": "算法竞赛",
|
||||
"color": "#52c5ea"
|
||||
},
|
||||
{
|
||||
"label": "ACM",
|
||||
"color": "#eb0e31"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_llm_extension",
|
||||
"project_link": "nonebot-plugin-llm-extension",
|
||||
"author_id": 110453675,
|
||||
"tags": [
|
||||
{
|
||||
"label": "🇦🇮",
|
||||
"color": "#f0f0f0"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_htmlkit",
|
||||
"project_link": "nonebot-plugin-htmlkit",
|
||||
"author_id": 50769752,
|
||||
"tags": [
|
||||
{
|
||||
"label": "模板渲染",
|
||||
"color": "#a57021"
|
||||
},
|
||||
{
|
||||
"label": "图片生成",
|
||||
"color": "#74c817"
|
||||
},
|
||||
{
|
||||
"label": "HTML渲染",
|
||||
"color": "#199579"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
{
|
||||
"module_name": "nonebot_plugin_mhcodes",
|
||||
"project_link": "nonebot-plugin-mhcodes",
|
||||
"author_id": 99017826,
|
||||
"tags": [
|
||||
{
|
||||
"label": "怪物猎人",
|
||||
"color": "#ea5252"
|
||||
}
|
||||
],
|
||||
"is_official": false
|
||||
},
|
||||
]
|
||||
|
@@ -42,6 +42,10 @@ UNKNOWN_PARAM = "Unknown parameter"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.xfail(
|
||||
(3, 13) <= sys.version_info < (3, 14),
|
||||
reason="CPython Bug, see python/cpython#137317, python/cpython#137862",
|
||||
)
|
||||
async def test_depend(app: App):
|
||||
from plugins.param.param_depend import (
|
||||
ClassDependency,
|
||||
|
@@ -289,7 +289,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
|
||||
`Arparma` 有如下属性:
|
||||
|
||||
- 调试类
|
||||
|
||||
- matched: 是否匹配成功
|
||||
- error_data: 解析失败时剩余的数据
|
||||
- error_info: 解析失败时的异常内容
|
||||
|
@@ -150,7 +150,7 @@ async def handle(
|
||||
|
||||
- `xxx: CommandResult`
|
||||
- `xxx: Arparma`:命令的[解析结果](./command.md#解析结果)
|
||||
- `xxx: Duplication`:命令的解析结果的 [`Duplication`](./command.md#Duplication)
|
||||
- `xxx: Duplication`:命令的解析结果的 [`Duplication`](./command.md#duplication)
|
||||
- `xxx: Alconna`:命令的源命令
|
||||
- `<key>: Match[<type>]`:上述的匹配项,使用 `key` 作为查询路径
|
||||
- `xxx: Query[<type>] = Query(<path>, default)`:上述的查询项,必需声明默认值以设置查询路径 `path`
|
||||
|
@@ -159,7 +159,7 @@ async def _(target: MsgTarget):
|
||||
|
||||
事实上,构造 `Target` 对象时,`self_id`, `scope`, `adapter` 和 `platform` 都会参与到 `selector` 的构造中。
|
||||
|
||||
::tip
|
||||
:::tip
|
||||
|
||||
你其实可以使用 `Target` 来帮你筛选 `Bot` 对象:
|
||||
|
||||
|
@@ -42,7 +42,7 @@ async def handle_function():
|
||||
|
||||
#### 处理近似事件
|
||||
|
||||
对于一系列**差异不大**的事件,我们往往具有相同的处理逻辑。这时,我们不希望将相同的逻辑编写两遍,而应该复用代码,以实现在同一个事件处理函数中处理多个近似事件。我们可以使用[事件重载](../advanced/dependency.mdx#Event)的特性来实现这一功能。例如:
|
||||
对于一系列**差异不大**的事件,我们往往具有相同的处理逻辑。这时,我们不希望将相同的逻辑编写两遍,而应该复用代码,以实现在同一个事件处理函数中处理多个近似事件。我们可以使用[事件重载](../advanced/dependency.mdx#event)的特性来实现这一功能。例如:
|
||||
|
||||
<Tabs groupId="python">
|
||||
<TabItem value="3.10" label="Python 3.10+" default>
|
||||
|
@@ -155,7 +155,6 @@ async def test_example(app: App):
|
||||
1. `should_call_send`
|
||||
|
||||
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
|
||||
|
||||
- `event`:回复的目标事件。
|
||||
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
|
||||
- `result`:send 的返回值,将会返回给插件。
|
||||
@@ -163,8 +162,7 @@ async def test_example(app: App):
|
||||
- `**kwargs`:send 方法的额外参数。
|
||||
|
||||
2. `should_call_api`
|
||||
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-API)进行的操作。`should_call_api` 有四个参数:
|
||||
|
||||
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
|
||||
- `api`:API 名称。
|
||||
- `data`:预期的请求数据。
|
||||
- `result`:call_api 的返回值,将会返回给插件。
|
||||
|
@@ -10,6 +10,9 @@ options:
|
||||
|
||||
# 手动创建项目
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
在[快速上手](../quick-start.mdx)中,我们已经介绍了如何安装和使用 `nb-cli` 创建一个项目。在本章节中,我们将简要介绍如何在不使用 `nb-cli` 的方式创建一个机器人项目的**最小实例**并启动。如果你想要了解 NoneBot 的启动流程,也可以阅读本章节。
|
||||
|
||||
:::caution 警告
|
||||
@@ -30,23 +33,51 @@ options:
|
||||
|
||||
1. (可选)创建虚拟环境,以 venv 为例
|
||||
|
||||
<Tabs groupId="platform">
|
||||
<TabItem value="windows" label="Windows" default>
|
||||
|
||||
```bash
|
||||
# 创建虚拟环境
|
||||
python -m venv .venv --prompt nonebot2
|
||||
# windows
|
||||
# 激活虚拟环境
|
||||
.venv\Scripts\activate
|
||||
# linux/macOS
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="linux/macos" label="Linux/macOS">
|
||||
|
||||
```bash
|
||||
# 创建虚拟环境
|
||||
python -m venv .venv --prompt nonebot2
|
||||
# 激活虚拟环境
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
2. 安装 nonebot2 以及驱动器
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
2. 安装 nonebot2 以及驱动器,以 Fastapi 驱动器为例
|
||||
|
||||
<Tabs groupId="platform">
|
||||
<TabItem value="windows" label="Windows" default>
|
||||
|
||||
```bash
|
||||
pip install 'nonebot2[fastapi]'
|
||||
pip install "nonebot2[fastapi]"
|
||||
```
|
||||
|
||||
驱动器包名可以在 [驱动器商店](/store/drivers) 中找到。
|
||||
</TabItem>
|
||||
<TabItem value="linux/macos" label="Linux/macOS">
|
||||
|
||||
3. 安装适配器
|
||||
```bash
|
||||
pip install "nonebot2[fastapi]"
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
驱动器包名可以在 [驱动器商店](/store/drivers) 中找到,请替换上文方括号中的内容。
|
||||
|
||||
3. 安装适配器,以 Console 适配器为例
|
||||
|
||||
```bash
|
||||
pip install nonebot-adapter-console
|
||||
@@ -58,7 +89,7 @@ options:
|
||||
|
||||
配置文件用于存放 NoneBot 运行所需要的配置项,使用 [`pydantic`](https://docs.pydantic.dev/) 以及 [`python-dotenv`](https://saurabh-kumar.com/python-dotenv/) 来读取配置。配置项需符合 dotenv 格式,复杂类型数据需使用 JSON 格式填写。具体可选配置方式以及配置项详情参考[配置](../appendices/config.mdx)。
|
||||
|
||||
在**项目文件夹**中创建一个 `.env` 文本文件,并写入以下内容:
|
||||
在**项目文件夹**中创建一个名为 `.env` 的文件,并写入以下内容:
|
||||
|
||||
```bash title=.env
|
||||
HOST=0.0.0.0 # 配置 NoneBot 监听的 IP / 主机名
|
||||
@@ -101,10 +132,29 @@ if __name__ == "__main__":
|
||||
|
||||
## 运行机器人
|
||||
|
||||
在**项目文件夹**中,使用配置好环境的 Python 解释器运行入口文件(如果使用虚拟环境,请先激活虚拟环境):
|
||||
在**项目文件夹**中,使用配置好环境的 Python 解释器运行入口文件:
|
||||
|
||||
<Tabs groupId="platform">
|
||||
<TabItem value="windows" label="Windows" default>
|
||||
|
||||
```bash
|
||||
# 激活虚拟环境(未使用虚拟环境时跳过此行)
|
||||
.venv\Scripts\activate
|
||||
# 运行机器人
|
||||
python bot.py
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="linux/macos" label="Linux/macOS">
|
||||
|
||||
```bash
|
||||
# 激活虚拟环境(未使用虚拟环境时跳过此行)
|
||||
source .venv/bin/activate
|
||||
# 运行机器人
|
||||
python bot.py
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
如果你后续使用了 `nb-cli` ,你仍可以使用 `nb run` 命令来运行机器人,`nb-cli` 会自动检测入口文件 `bot.py` 是否存在并运行。同时,你也可以使用 `nb run --reload` 来自动检测代码的更改并自动重新运行入口文件。
|
@@ -64,7 +64,7 @@ options:
|
||||
:::
|
||||
|
||||
:::caution 注意
|
||||
如果在之前的[创建项目](./application.md)章节中手动创建了相关文件,那么你需要做出如下修改:
|
||||
如果在之前的[创建项目](./application.mdx)章节中手动创建了相关文件,那么你需要做出如下修改:
|
||||
|
||||
1. 在项目目录中创建一个两层文件夹 `awesome_bot/plugins`
|
||||
|
||||
|
@@ -300,6 +300,7 @@ export default async function createConfigAsync() {
|
||||
|
||||
future: {
|
||||
experimental_faster: true,
|
||||
v4: true,
|
||||
},
|
||||
|
||||
plugins: [
|
||||
|
@@ -5,6 +5,58 @@ toc_max_heading_level: 2
|
||||
|
||||
# 更新日志
|
||||
|
||||
## 最近更新
|
||||
|
||||
### 📝 文档
|
||||
|
||||
- Docs: 修复 userinfo 插件链接 [@XieXiLin2](https://github.com/XieXiLin2) ([#3660](https://github.com/nonebot/nonebot2/pull/3660))
|
||||
- Docs: 升级 docusaurus 3.8.1 [@StarHeartHunt](https://github.com/StarHeartHunt) ([#3649](https://github.com/nonebot/nonebot2/pull/3649))
|
||||
- Docs: 更新文档《手动创建项目》 [@Chen-Luan](https://github.com/Chen-Luan) ([#3623](https://github.com/nonebot/nonebot2/pull/3623))
|
||||
- Docs: 增加 B站直播间 适配器说明 [@MingxuanGame](https://github.com/MingxuanGame) ([#3636](https://github.com/nonebot/nonebot2/pull/3636))
|
||||
- Docs: 增加 VoceChat 适配器说明 [@5656565566](https://github.com/5656565566) ([#3627](https://github.com/nonebot/nonebot2/pull/3627))
|
||||
|
||||
### 💫 杂项
|
||||
|
||||
- CI: 升级文档构建 node 版本 [@StarHeartHunt](https://github.com/StarHeartHunt) ([#3668](https://github.com/nonebot/nonebot2/pull/3668))
|
||||
- CI: 测试矩阵加入 Python 3.13 [@StarHeartHunt](https://github.com/StarHeartHunt) ([#3605](https://github.com/nonebot/nonebot2/pull/3605))
|
||||
|
||||
### 🍻 插件发布
|
||||
|
||||
- Plugin: 怪物猎人集会码插件 [@noneflow](https://github.com/noneflow) ([#3684](https://github.com/nonebot/nonebot2/pull/3684))
|
||||
- Plugin: nonebot-plugin-htmlkit [@noneflow](https://github.com/noneflow) ([#3695](https://github.com/nonebot/nonebot2/pull/3695))
|
||||
- Plugin: 言令 [@noneflow](https://github.com/noneflow) ([#3675](https://github.com/nonebot/nonebot2/pull/3675))
|
||||
- Plugin: 算法比赛助手 [@noneflow](https://github.com/noneflow) ([#3672](https://github.com/nonebot/nonebot2/pull/3672))
|
||||
- Plugin: 复盘打卡 [@noneflow](https://github.com/noneflow) ([#3681](https://github.com/nonebot/nonebot2/pull/3681))
|
||||
- Plugin: DMP 饥荒管理平台机器人 [@noneflow](https://github.com/noneflow) ([#3616](https://github.com/nonebot/nonebot2/pull/3616))
|
||||
- Plugin: 谁是卧底小游戏 [@noneflow](https://github.com/noneflow) ([#3629](https://github.com/nonebot/nonebot2/pull/3629))
|
||||
- Plugin: 夸克自动转存 [@noneflow](https://github.com/noneflow) ([#3671](https://github.com/nonebot/nonebot2/pull/3671))
|
||||
- Plugin: 禁止复读 [@noneflow](https://github.com/noneflow) ([#3644](https://github.com/nonebot/nonebot2/pull/3644))
|
||||
- Plugin: 蔚蓝档案今日运势 [@noneflow](https://github.com/noneflow) ([#3653](https://github.com/nonebot/nonebot2/pull/3653))
|
||||
- Plugin: 分布式黑名单插件 [@noneflow](https://github.com/noneflow) ([#3655](https://github.com/nonebot/nonebot2/pull/3655))
|
||||
- Plugin: 图片手办化 [@noneflow](https://github.com/noneflow) ([#3662](https://github.com/nonebot/nonebot2/pull/3662))
|
||||
- Plugin: Akash Image Generator [@noneflow](https://github.com/noneflow) ([#3651](https://github.com/nonebot/nonebot2/pull/3651))
|
||||
- Plugin: 让我看看!! [@noneflow](https://github.com/noneflow) ([#3648](https://github.com/nonebot/nonebot2/pull/3648))
|
||||
- Plugin: ImageLibrary [@noneflow](https://github.com/noneflow) ([#3620](https://github.com/nonebot/nonebot2/pull/3620))
|
||||
- Plugin: 抽象 [@noneflow](https://github.com/noneflow) ([#3638](https://github.com/nonebot/nonebot2/pull/3638))
|
||||
- Plugin: 卖若插件 [@noneflow](https://github.com/noneflow) ([#3631](https://github.com/nonebot/nonebot2/pull/3631))
|
||||
- Plugin: HuaEr聊天bot [@noneflow](https://github.com/noneflow) ([#3564](https://github.com/nonebot/nonebot2/pull/3564))
|
||||
- Plugin: Remove nonebot_plugin_cnrail [@noneflow](https://github.com/noneflow) ([#3645](https://github.com/nonebot/nonebot2/pull/3645))
|
||||
- Plugin: Remove nonebot_plugin_pingti [@noneflow](https://github.com/noneflow) ([#3646](https://github.com/nonebot/nonebot2/pull/3646))
|
||||
- Plugin: Anipusher推送机 [@noneflow](https://github.com/noneflow) ([#3582](https://github.com/nonebot/nonebot2/pull/3582))
|
||||
- Plugin: nonebot-plugin-simple-setu [@noneflow](https://github.com/noneflow) ([#3594](https://github.com/nonebot/nonebot2/pull/3594))
|
||||
- Plugin: Alisten [@noneflow](https://github.com/noneflow) ([#3635](https://github.com/nonebot/nonebot2/pull/3635))
|
||||
- Plugin: MC玩家皮肤渲染 [@noneflow](https://github.com/noneflow) ([#3613](https://github.com/nonebot/nonebot2/pull/3613))
|
||||
- Plugin: EconomyValue [@noneflow](https://github.com/noneflow) ([#3566](https://github.com/nonebot/nonebot2/pull/3566))
|
||||
|
||||
### 🍻 机器人发布
|
||||
|
||||
- Bot: Amrita [@noneflow](https://github.com/noneflow) ([#3641](https://github.com/nonebot/nonebot2/pull/3641))
|
||||
|
||||
### 🍻 适配器发布
|
||||
|
||||
- Adapter: B站直播间 [@noneflow](https://github.com/noneflow) ([#3592](https://github.com/nonebot/nonebot2/pull/3592))
|
||||
- Adapter: nonebot-adapter-vocechat [@noneflow](https://github.com/noneflow) ([#3536](https://github.com/nonebot/nonebot2/pull/3536))
|
||||
|
||||
## v2.4.3
|
||||
|
||||
### 🚀 新功能
|
||||
|
@@ -20,7 +20,6 @@ description: nonebot.adapters 模块
|
||||
通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例
|
||||
|
||||
- `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数
|
||||
@@ -46,7 +45,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _property_ `config` {#Adapter-config}
|
||||
@@ -64,11 +62,9 @@ description: nonebot.adapters 模块
|
||||
当有新的 [Bot](#Bot) 实例连接建立成功时调用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect}
|
||||
@@ -80,11 +76,9 @@ description: nonebot.adapters 模块
|
||||
当有 [Bot](#Bot) 实例连接断开时调用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server}
|
||||
@@ -92,11 +86,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 设置一个 HTTP 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server}
|
||||
@@ -104,11 +96,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 设置一个 WebSocket 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `request(setup)` {#Adapter-request}
|
||||
@@ -116,11 +106,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 进行一个 HTTP 客户端请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](../drivers/index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](../drivers/index.md#Response)
|
||||
|
||||
### _method_ `websocket(setup)` {#Adapter-websocket}
|
||||
@@ -128,21 +116,17 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 建立一个 WebSocket 客户端连接请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](../drivers/index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None]
|
||||
|
||||
### _method_ `on_ready(func)` {#Adapter-on-ready}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
## _abstract class_ `Bot(adapter, self_id)` {#Bot}
|
||||
@@ -154,7 +138,6 @@ description: nonebot.adapters 模块
|
||||
用于处理上报消息,并提供 API 调用接口。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter` ([Adapter](#Adapter)): 协议适配器实例
|
||||
|
||||
- `self_id` (str): 机器人 ID
|
||||
@@ -188,13 +171,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
|
||||
|
||||
- **参数**
|
||||
|
||||
- `api` (str): API 名称
|
||||
|
||||
- `**data` (Any): API 数据
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
- **用法**
|
||||
@@ -209,7 +190,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 调用机器人基础发送消息接口
|
||||
|
||||
- **参数**
|
||||
|
||||
- `event` ([Event](#Event)): 上报事件
|
||||
|
||||
- `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息
|
||||
@@ -217,7 +197,6 @@ description: nonebot.adapters 模块
|
||||
- `**kwargs` (Any): 任意额外参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api}
|
||||
@@ -227,17 +206,14 @@ description: nonebot.adapters 模块
|
||||
调用 api 预处理。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前 bot 对象
|
||||
- api: 调用的 api 名称
|
||||
- data: api 调用的参数字典
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_CallingAPIHook](../typing.md#T-CallingAPIHook)
|
||||
|
||||
### _classmethod_ `on_called_api(func)` {#Bot-on-called-api}
|
||||
@@ -247,7 +223,6 @@ description: nonebot.adapters 模块
|
||||
调用 api 后处理。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前 bot 对象
|
||||
- exception: 调用 api 时发生的错误
|
||||
- api: 调用的 api 名称
|
||||
@@ -255,11 +230,9 @@ description: nonebot.adapters 模块
|
||||
- result: api 调用的返回
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_CalledAPIHook](../typing.md#T-CalledAPIHook)
|
||||
|
||||
## _abstract class_ `Event(<auto>)` {#Event}
|
||||
@@ -279,7 +252,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_event_name()` {#Event-get-event-name}
|
||||
@@ -291,7 +263,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_event_description()` {#Event-get-event-description}
|
||||
@@ -303,7 +274,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _method_ `get_log_string()` {#Event-get-log-string}
|
||||
@@ -320,11 +290,9 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
- **异常**
|
||||
|
||||
- NoLogException: 希望 NoneBot 隐藏该事件日志
|
||||
|
||||
### _abstract method_ `get_user_id()` {#Event-get-user-id}
|
||||
@@ -336,7 +304,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_session_id()` {#Event-get-session-id}
|
||||
@@ -348,7 +315,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_message()` {#Event-get-message}
|
||||
@@ -360,7 +326,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](#Message)
|
||||
|
||||
### _method_ `get_plaintext()` {#Event-get-plaintext}
|
||||
@@ -376,7 +341,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `is_tome()` {#Event-is-tome}
|
||||
@@ -388,7 +352,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _abstract class_ `Message(<auto>)` {#Message}
|
||||
@@ -396,7 +359,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 消息序列
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message`: 消息内容
|
||||
|
||||
### _classmethod_ `template(format_string)` {#Message-template}
|
||||
@@ -410,11 +372,9 @@ description: nonebot.adapters 模块
|
||||
可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `format_string` (str | TM): 格式化模板
|
||||
|
||||
- **返回**
|
||||
|
||||
- [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器
|
||||
|
||||
### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class}
|
||||
@@ -426,7 +386,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[TMS]
|
||||
|
||||
### _abstract staticmethod_ `_construct(msg)` {#Message--construct}
|
||||
@@ -434,11 +393,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 构造消息数组
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Iterable[TMS]
|
||||
|
||||
### _method_ `__getitem__(args)` {#Message---getitem--}
|
||||
@@ -446,53 +403,38 @@ description: nonebot.adapters 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (str): 消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 所有类型为 `args` 的消息段
|
||||
|
||||
**2.** `(args) -> TMS`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (tuple[str, int]): 消息段类型和索引
|
||||
|
||||
- **返回**
|
||||
|
||||
- TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个
|
||||
|
||||
**3.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (tuple[str, slice]): 消息段类型和切片
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 类型为 `args[0]` 的消息段切片 `args[1]`
|
||||
|
||||
**4.** `(args) -> TMS`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (int): 索引
|
||||
|
||||
- **返回**
|
||||
|
||||
- TMS: 第 `args` 个消息段
|
||||
|
||||
**5.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (slice): 切片
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 消息切片 `args`
|
||||
|
||||
### _method_ `__contains__(value)` {#Message---contains--}
|
||||
@@ -500,11 +442,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 检查消息段是否存在
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 消息内是否存在给定消息段或给定类型的消息段
|
||||
|
||||
### _method_ `has(value)` {#Message-has}
|
||||
@@ -512,11 +452,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 与 [`__contains__`](#Message---contains--) 相同
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
### _method_ `index(value, *args)` {#Message-index}
|
||||
@@ -524,7 +462,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 索引消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或者消息段类型
|
||||
|
||||
- `*args` (SupportsIndex)
|
||||
@@ -532,11 +469,9 @@ description: nonebot.adapters 模块
|
||||
- `arg`: start 与 end
|
||||
|
||||
- **返回**
|
||||
|
||||
- int: 索引 index
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 消息段不存在
|
||||
|
||||
### _method_ `get(type_, count=None)` {#Message-get}
|
||||
@@ -544,13 +479,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 获取指定类型的消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (str): 消息段类型
|
||||
|
||||
- `count` (int | None): 获取个数
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 构建的新消息
|
||||
|
||||
### _method_ `count(value)` {#Message-count}
|
||||
@@ -558,11 +491,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 计算指定消息段的个数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- int: 个数
|
||||
|
||||
### _method_ `only(value)` {#Message-only}
|
||||
@@ -570,11 +501,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 检查消息中是否仅包含指定消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 指定消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否仅包含指定消息段
|
||||
|
||||
### _method_ `append(obj)` {#Message-append}
|
||||
@@ -582,11 +511,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 添加一个消息段到消息数组末尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (str | TMS): 要添加的消息段
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `extend(obj)` {#Message-extend}
|
||||
@@ -594,11 +521,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (Self | Iterable[TMS]): 要添加的消息数组
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `join(iterable)` {#Message-join}
|
||||
@@ -606,11 +531,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 将多个消息连接并将自身作为分割
|
||||
|
||||
- **参数**
|
||||
|
||||
- `iterable` (Iterable[TMS | Self]): 要连接的消息
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 连接后的消息
|
||||
|
||||
### _method_ `copy()` {#Message-copy}
|
||||
@@ -622,7 +545,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `include(*types)` {#Message-include}
|
||||
@@ -630,11 +552,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 过滤消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (str): 包含的消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 新构造的消息
|
||||
|
||||
### _method_ `exclude(*types)` {#Message-exclude}
|
||||
@@ -642,11 +562,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 过滤消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (str): 不包含的消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 新构造的消息
|
||||
|
||||
### _method_ `extract_plain_text()` {#Message-extract-plain-text}
|
||||
@@ -658,7 +576,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment}
|
||||
@@ -690,7 +607,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[TM]
|
||||
|
||||
### _abstract method_ `__str__()` {#MessageSegment---str--}
|
||||
@@ -702,29 +618,24 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _method_ `__add__(other)` {#MessageSegment---add--}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `other` (str | TMS | Iterable[TMS])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TM
|
||||
|
||||
### _method_ `get(key, default=None)` {#MessageSegment-get}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `keys()` {#MessageSegment-keys}
|
||||
@@ -734,7 +645,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `values()` {#MessageSegment-values}
|
||||
@@ -744,7 +654,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `items()` {#MessageSegment-items}
|
||||
@@ -754,17 +663,14 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `join(iterable)` {#MessageSegment-join}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `iterable` (Iterable[TMS | TM])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TM
|
||||
|
||||
### _method_ `copy()` {#MessageSegment-copy}
|
||||
@@ -774,7 +680,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _abstract method_ `is_text()` {#MessageSegment-is-text}
|
||||
@@ -786,7 +691,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate}
|
||||
@@ -794,7 +698,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 消息模板格式化实现类。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `template` (str | TM): 模板
|
||||
|
||||
- `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str`
|
||||
@@ -804,13 +707,11 @@ description: nonebot.adapters 模块
|
||||
### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `spec` (FormatSpecFunc_T)
|
||||
|
||||
- `name` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- FormatSpecFunc_T
|
||||
|
||||
### _method_ `format(*args, **kwargs)` {#MessageTemplate-format}
|
||||
@@ -818,13 +719,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 根据传入参数和模板生成消息对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `format_map(mapping)` {#MessageTemplate-format-map}
|
||||
@@ -832,17 +731,14 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用
|
||||
|
||||
- **参数**
|
||||
|
||||
- `mapping` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `format_string` (str)
|
||||
|
||||
- `args` (Sequence[Any])
|
||||
@@ -850,13 +746,11 @@ description: nonebot.adapters 模块
|
||||
- `kwargs` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field_name` (str)
|
||||
|
||||
- `args` (Sequence[Any])
|
||||
@@ -864,17 +758,14 @@ description: nonebot.adapters 模块
|
||||
- `kwargs` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Any, int | str]
|
||||
|
||||
### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- `format_spec` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -36,7 +36,6 @@ description: nonebot.compat 模块
|
||||
- **说明:** FieldInfo class with extra property for compatibility with pydantic v1
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- `**kwargs` (Any)
|
||||
@@ -82,7 +81,6 @@ description: nonebot.compat 模块
|
||||
- **说明:** Construct a ModelField from given infos.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `annotation` (Any)
|
||||
@@ -90,7 +88,6 @@ description: nonebot.compat 模块
|
||||
- `field_info` (FieldInfo | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `get_default()` {#ModelField-get-default}
|
||||
@@ -102,7 +99,6 @@ description: nonebot.compat 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _method_ `validate_value(value)` {#ModelField-validate-value}
|
||||
@@ -110,11 +106,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate the value pass to the field.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `extract_field_info(field_info)` {#extract-field-info}
|
||||
@@ -122,11 +116,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get FieldInfo init kwargs from a FieldInfo instance.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field_info` (BaseFieldInfo)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `model_fields(model)` {#model-fields}
|
||||
@@ -134,11 +126,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get field list of a model.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (type[BaseModel])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[ModelField]
|
||||
|
||||
## _def_ `model_config(model)` {#model-config}
|
||||
@@ -146,17 +136,14 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get config of a model.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (type[BaseModel])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (BaseModel)
|
||||
|
||||
- `include` (set[str] | None)
|
||||
@@ -172,7 +159,6 @@ description: nonebot.compat 模块
|
||||
- `exclude_none` (bool)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `type_validate_python(type_, data)` {#type-validate-python}
|
||||
@@ -180,13 +166,11 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate data with given type.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[T])
|
||||
|
||||
- `data` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T
|
||||
|
||||
## _def_ `type_validate_json(type_, data)` {#type-validate-json}
|
||||
@@ -194,13 +178,11 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate JSON with given type.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[T])
|
||||
|
||||
- `data` (str | bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T
|
||||
|
||||
## _def_ `custom_validation(class_)` {#custom-validation}
|
||||
@@ -208,9 +190,7 @@ description: nonebot.compat 模块
|
||||
- **说明:** Use pydantic v1 like validator generator in pydantic v2
|
||||
|
||||
- **参数**
|
||||
|
||||
- `class_` (type[CVC])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[CVC]
|
||||
|
@@ -24,7 +24,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
|
||||
将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None)
|
||||
|
||||
- `_env_file_encoding` (str | None)
|
||||
@@ -55,7 +54,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
|
||||
配置方法参考: [配置](https://nonebot.dev/docs/appendices/config)
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None)
|
||||
|
||||
- `_env_file_encoding` (str | None)
|
||||
|
@@ -18,7 +18,6 @@ description: nonebot.dependencies 模块
|
||||
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -30,7 +29,6 @@ description: nonebot.dependencies 模块
|
||||
- **说明:** 依赖注入容器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call`: 依赖注入的可调用对象,可以是任何 Callable 对象
|
||||
|
||||
- `pre_checkers`: 依赖注入解析前的参数检查
|
||||
@@ -44,31 +42,26 @@ description: nonebot.dependencies 模块
|
||||
### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` (\_DependentCallable[R])
|
||||
|
||||
- `allow_types` (tuple[type[Param], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[[ModelField](../compat.md#ModelField), ...]
|
||||
|
||||
### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `parameterless` (tuple[Any, ...])
|
||||
|
||||
- `allow_types` (tuple[type[Param], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Param, ...]
|
||||
|
||||
### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` (\_DependentCallable[R])
|
||||
|
||||
- `parameterless` (Iterable[Any] | None)
|
||||
@@ -76,25 +69,20 @@ description: nonebot.dependencies 模块
|
||||
- `allow_types` (Iterable[type[Param]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Dependent[R]
|
||||
|
||||
### _async method_ `check(**params)` {#Dependent-check}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `**params` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `solve(**params)` {#Dependent-solve}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `**params` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
@@ -12,11 +12,9 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 获取可调用对象签名
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- inspect.Signature
|
||||
|
||||
## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation}
|
||||
@@ -24,13 +22,11 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 获取参数的类型注解
|
||||
|
||||
- **参数**
|
||||
|
||||
- `param` (inspect.Parameter)
|
||||
|
||||
- `globalns` (dict[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `check_field_type(field, value)` {#check-field-type}
|
||||
@@ -38,11 +34,9 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 检查字段类型是否匹配
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field` ([ModelField](../compat.md#ModelField))
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -22,7 +22,6 @@ pip install nonebot2[aiohttp]
|
||||
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -38,11 +37,9 @@ pip install nonebot2[aiohttp]
|
||||
### _async method_ `request(setup)` {#Session-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _async method_ `setup()` {#Session-setup}
|
||||
@@ -52,7 +49,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close()` {#Session-close}
|
||||
@@ -62,7 +58,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -76,27 +71,22 @@ pip install nonebot2[aiohttp]
|
||||
### _async method_ `request(setup)` {#Mixin-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `websocket(setup)` {#Mixin-websocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](index.md#WebSocket), None]
|
||||
|
||||
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -110,7 +100,6 @@ pip install nonebot2[aiohttp]
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Session
|
||||
|
||||
## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket}
|
||||
@@ -118,7 +107,6 @@ pip install nonebot2[aiohttp]
|
||||
- **说明:** AIOHTTP Websocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` ([Request](index.md#Request))
|
||||
|
||||
- `session` (aiohttp.ClientSession)
|
||||
@@ -132,19 +120,16 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -154,7 +139,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -164,7 +148,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -174,33 +157,27 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -92,7 +92,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** FastAPI 驱动框架。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` (NoneBotConfig)
|
||||
@@ -124,21 +123,17 @@ pip install nonebot2[fastapi]
|
||||
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
|
||||
@@ -146,7 +141,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** 使用 `uvicorn` 启动 FastAPI
|
||||
|
||||
- **参数**
|
||||
|
||||
- `host` (str | None)
|
||||
|
||||
- `port` (int | None)
|
||||
@@ -158,7 +152,6 @@ pip install nonebot2[fastapi]
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket}
|
||||
@@ -166,7 +159,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** FastAPI WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (BaseRequest)
|
||||
|
||||
- `websocket` ([WebSocket](index.md#WebSocket))
|
||||
@@ -178,19 +170,16 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `receive()` {#FastAPIWebSocket-receive}
|
||||
@@ -200,7 +189,6 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text}
|
||||
@@ -210,7 +198,6 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes}
|
||||
@@ -220,25 +207,20 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
@@ -22,7 +22,6 @@ pip install nonebot2[httpx]
|
||||
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -38,11 +37,9 @@ pip install nonebot2[httpx]
|
||||
### _async method_ `request(setup)` {#Session-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _async method_ `setup()` {#Session-setup}
|
||||
@@ -52,7 +49,6 @@ pip install nonebot2[httpx]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close()` {#Session-close}
|
||||
@@ -62,7 +58,6 @@ pip install nonebot2[httpx]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -76,17 +71,14 @@ pip install nonebot2[httpx]
|
||||
### _async method_ `request(setup)` {#Mixin-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -100,13 +92,11 @@ pip install nonebot2[httpx]
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Session
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -40,11 +40,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 设置一个 HTTP 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server}
|
||||
@@ -52,23 +50,19 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 设置一个 WebSocket 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Cookies(cookies=None)` {#Cookies}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cookies` (CookieTypes)
|
||||
|
||||
### _method_ `set(name, value, domain="", path="/")` {#Cookies-set}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `value` (str)
|
||||
@@ -78,13 +72,11 @@ description: nonebot.drivers 模块
|
||||
- `path` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `default` (str | None)
|
||||
@@ -94,13 +86,11 @@ description: nonebot.drivers 模块
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | None
|
||||
|
||||
### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `domain` (str | None)
|
||||
@@ -108,39 +98,32 @@ description: nonebot.drivers 模块
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `clear(domain=None, path=None)` {#Cookies-clear}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `domain` (str | None)
|
||||
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `update(cookies=None)` {#Cookies-update}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cookies` (CookieTypes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `as_header(request)` {#Cookies-as-header}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (Request)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, str]
|
||||
|
||||
## _abstract class_ `Driver(env, config)` {#Driver}
|
||||
@@ -152,7 +135,6 @@ description: nonebot.drivers 模块
|
||||
驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象
|
||||
|
||||
- `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象
|
||||
@@ -180,13 +162,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个协议适配器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类
|
||||
|
||||
- `**kwargs`: 其他传递给适配器的参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract property_ `type` {#Driver-type}
|
||||
@@ -206,13 +186,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 启动驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `on_startup(func)` {#Driver-on-startup}
|
||||
@@ -220,11 +198,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个启动时执行的函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
### _method_ `on_shutdown(func)` {#Driver-on-shutdown}
|
||||
@@ -232,11 +208,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个停止时执行的函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect}
|
||||
@@ -246,15 +220,12 @@ description: nonebot.drivers 模块
|
||||
装饰一个函数使他在 bot 连接成功时执行。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前连接上的 Bot 对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_BotConnectionHook](../typing.md#T-BotConnectionHook)
|
||||
|
||||
### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect}
|
||||
@@ -264,15 +235,12 @@ description: nonebot.drivers 模块
|
||||
装饰一个函数使他在 bot 连接断开时执行。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前连接上的 Bot 对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)
|
||||
|
||||
## _var_ `ForwardDriver` {#ForwardDriver}
|
||||
@@ -306,11 +274,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一个 HTTP 请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](#Response)
|
||||
|
||||
### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session}
|
||||
@@ -318,7 +284,6 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 获取一个 HTTP 会话
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -332,7 +297,6 @@ description: nonebot.drivers 模块
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- HTTPClientSession
|
||||
|
||||
## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup}
|
||||
@@ -350,7 +314,6 @@ description: nonebot.drivers 模块
|
||||
- **参数**
|
||||
|
||||
auto
|
||||
|
||||
- `H10: '1.0'`
|
||||
|
||||
- `H11: '1.1'`
|
||||
@@ -374,7 +337,6 @@ description: nonebot.drivers 模块
|
||||
## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `method` (str | bytes)
|
||||
|
||||
- `url` (URL | str | RawURL)
|
||||
@@ -402,7 +364,6 @@ description: nonebot.drivers 模块
|
||||
## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `status_code` (int)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -432,7 +393,6 @@ description: nonebot.drivers 模块
|
||||
## _abstract class_ `WebSocket(*, request)` {#WebSocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (Request)
|
||||
|
||||
### _abstract property_ `closed` {#WebSocket-closed}
|
||||
@@ -450,7 +410,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
@@ -458,13 +417,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 关闭 WebSocket 连接请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -476,7 +433,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _abstract async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -488,7 +444,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -500,7 +455,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send(data)` {#WebSocket-send}
|
||||
@@ -508,11 +462,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket text/bytes 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str | bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
@@ -520,11 +472,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket text 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
@@ -532,11 +482,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket binary 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin}
|
||||
@@ -552,11 +500,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发起一个 WebSocket 连接
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](#WebSocket), None]
|
||||
|
||||
## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup}
|
||||
@@ -574,19 +520,14 @@ description: nonebot.drivers 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(driver) -> type[D]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` (type[D])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[D]
|
||||
|
||||
**2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` (type[D])
|
||||
|
||||
- `__m` (type[[Mixin](#Mixin)])
|
||||
@@ -594,5 +535,4 @@ description: nonebot.drivers 模块
|
||||
- `*mixins` (type[[Mixin](#Mixin)])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[CombinedDriver]
|
||||
|
@@ -18,7 +18,6 @@ None 驱动适配
|
||||
- **说明:** None 驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
@@ -40,13 +39,11 @@ None 驱动适配
|
||||
- **说明:** 启动 none driver
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `exit(force=False)` {#Driver-exit}
|
||||
@@ -54,9 +51,7 @@ None 驱动适配
|
||||
- **说明:** 退出 none driver
|
||||
|
||||
- **参数**
|
||||
|
||||
- `force` (bool): 强制退出
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
@@ -68,7 +68,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** Quart 驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` (NoneBotConfig)
|
||||
@@ -100,21 +99,17 @@ pip install nonebot2[quart]
|
||||
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
|
||||
@@ -122,7 +117,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** 使用 `uvicorn` 启动 Quart
|
||||
|
||||
- **参数**
|
||||
|
||||
- `host` (str | None)
|
||||
|
||||
- `port` (int | None)
|
||||
@@ -134,7 +128,6 @@ pip install nonebot2[quart]
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket}
|
||||
@@ -142,7 +135,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** Quart WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (BaseRequest)
|
||||
|
||||
- `websocket_ctx` (WebsocketContext)
|
||||
@@ -154,19 +146,16 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -176,7 +165,6 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -186,7 +174,6 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -196,25 +183,20 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
@@ -22,11 +22,9 @@ pip install nonebot2[websockets]
|
||||
## _def_ `catch_closed(func)` {#catch-closed}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ((P) -> Coroutine[Any, Any, T])
|
||||
|
||||
- **返回**
|
||||
|
||||
- (P) -> Coroutine[Any, Any, T]
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -40,11 +38,9 @@ pip install nonebot2[websockets]
|
||||
### _method_ `websocket(setup)` {#Mixin-websocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](index.md#WebSocket), None]
|
||||
|
||||
## _class_ `WebSocket(*, request, websocket)` {#WebSocket}
|
||||
@@ -52,7 +48,6 @@ pip install nonebot2[websockets]
|
||||
- **说明:** Websockets WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` ([Request](index.md#Request))
|
||||
|
||||
- `websocket` (WebSocketClientProtocol)
|
||||
@@ -64,19 +59,16 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -86,7 +78,6 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -96,7 +87,6 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -106,33 +96,27 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -62,7 +62,6 @@ NoneBotException
|
||||
- **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `reason`: 忽略事件的原因
|
||||
|
||||
## _class_ `SkippedException(<auto>)` {#SkippedException}
|
||||
@@ -101,7 +100,6 @@ NoneBotException
|
||||
- **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `result`: 返回的内容
|
||||
|
||||
## _class_ `StopPropagation(<auto>)` {#StopPropagation}
|
||||
@@ -200,7 +198,6 @@ NoneBotException
|
||||
- **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter_name`: 标识 adapter
|
||||
|
||||
## _class_ `NoLogException(<auto>)` {#NoLogException}
|
||||
|
@@ -60,11 +60,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -80,27 +78,20 @@ description: nonebot 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(name) -> Adapter`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 适配器名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象
|
||||
|
||||
**2.** `(name) -> A`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (type[A]): 适配器类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -121,11 +112,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -143,11 +132,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any: Server App 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -167,11 +154,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any: ASGI 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -192,15 +177,12 @@ description: nonebot 模块
|
||||
当不提供时,返回一个 [Bot](adapters/index.md#Bot)。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- KeyError: 对应 self_id 的 Bot 不存在
|
||||
|
||||
- ValueError: 没有传入 self_id 且没有 Bot 可用
|
||||
@@ -224,13 +206,11 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键
|
||||
|
||||
[Bot](adapters/index.md#Bot) 对象为值的字典
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -250,13 +230,11 @@ description: nonebot 模块
|
||||
也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置
|
||||
|
||||
- `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
@@ -270,13 +248,11 @@ description: nonebot 模块
|
||||
- **说明:** 启动 NoneBot,即运行全局 [Driver](drivers/index.md#Driver) 对象。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数
|
||||
|
||||
- `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
|
@@ -25,7 +25,6 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||||
NoneBot 日志记录器对象。
|
||||
|
||||
默认信息:
|
||||
|
||||
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
|
||||
- 等级: `INFO` ,根据 `config.log_level` 配置改变
|
||||
- 输出: 输出至 stdout
|
||||
@@ -47,11 +46,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||||
### _method_ `emit(record)` {#LoguruHandler-emit}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `record` (logging.LogRecord)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _def_ `default_filter(record)` {#default-filter}
|
||||
@@ -59,11 +56,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||||
- **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `record` (Record)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _var_ `default_format` {#default-format}
|
||||
|
@@ -76,7 +76,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意
|
||||
|
||||
- `rule` ([Rule](rule.md#Rule) | None): 匹配规则
|
||||
@@ -106,7 +105,6 @@ description: nonebot.matcher 模块
|
||||
- `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[Matcher]: 新的事件响应器类
|
||||
|
||||
### _classmethod_ `destroy()` {#Matcher-destroy}
|
||||
@@ -118,7 +116,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm}
|
||||
@@ -126,7 +123,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 检查是否满足触发权限
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): 上报事件
|
||||
@@ -136,7 +132,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否满足权限
|
||||
|
||||
### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule}
|
||||
@@ -144,7 +139,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 检查是否满足匹配规则
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): 上报事件
|
||||
@@ -156,7 +150,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否满足匹配规则
|
||||
|
||||
### _classmethod_ `type_updater(func)` {#Matcher-type-updater}
|
||||
@@ -164,11 +157,9 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_TypeUpdater](typing.md#T-TypeUpdater)
|
||||
|
||||
### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater}
|
||||
@@ -176,23 +167,19 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_PermissionUpdater](typing.md#T-PermissionUpdater)
|
||||
|
||||
### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `handler` ([T_Handler](typing.md#T-Handler))
|
||||
|
||||
- `parameterless` (Iterable[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Dependent](dependencies/index.md#Dependent)[Any]
|
||||
|
||||
### _classmethod_ `handle(parameterless=None)` {#Matcher-handle}
|
||||
@@ -200,11 +187,9 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
|
||||
|
||||
### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive}
|
||||
@@ -212,13 +197,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str): 消息 ID
|
||||
|
||||
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
|
||||
|
||||
### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got}
|
||||
@@ -231,7 +214,6 @@ description: nonebot.matcher 模块
|
||||
如果 `key` 已存在则直接继续运行
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str): 参数名
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息
|
||||
@@ -239,7 +221,6 @@ description: nonebot.matcher 模块
|
||||
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
|
||||
|
||||
### _classmethod_ `send(message, **kwargs)` {#Matcher-send}
|
||||
@@ -247,13 +228,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 发送一条消息给当前交互用户
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容
|
||||
|
||||
- `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish}
|
||||
@@ -261,13 +240,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 发送一条消息给当前交互用户并结束当前事件响应器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause}
|
||||
@@ -275,13 +252,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject}
|
||||
@@ -289,13 +264,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg}
|
||||
@@ -303,7 +276,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str): 参数名
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
@@ -311,7 +283,6 @@ description: nonebot.matcher 模块
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive}
|
||||
@@ -319,7 +290,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str): 消息 id
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
@@ -327,7 +297,6 @@ description: nonebot.matcher 模块
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `skip()` {#Matcher-skip}
|
||||
@@ -343,7 +312,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _method_ `get_receive(id, default=None)` {#Matcher-get-receive}
|
||||
@@ -357,25 +325,19 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(id) -> Event | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | None
|
||||
|
||||
**2.** `(id, default) -> Event | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str)
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | T
|
||||
|
||||
### _method_ `set_receive(id, event)` {#Matcher-set-receive}
|
||||
@@ -383,13 +345,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 设置一个 `receive` 事件
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str)
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive}
|
||||
@@ -403,23 +363,18 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `() -> Event | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | None
|
||||
|
||||
**2.** `(default) -> Event | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | T
|
||||
|
||||
### _method_ `get_arg(key, default=None)` {#Matcher-get-arg}
|
||||
@@ -433,25 +388,19 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(key) -> Message | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](adapters/index.md#Message) | None
|
||||
|
||||
**2.** `(key, default) -> Message | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](adapters/index.md#Message) | T
|
||||
|
||||
### _method_ `set_arg(key, message)` {#Matcher-set-arg}
|
||||
@@ -459,25 +408,21 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 设置一个 `got` 消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `message` ([Message](adapters/index.md#Message))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `set_target(target, cache=True)` {#Matcher-set-target}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `target` (str)
|
||||
|
||||
- `cache` (bool)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get_target(default=None)` {#Matcher-get-target}
|
||||
@@ -485,23 +430,18 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `() -> str | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | None
|
||||
|
||||
**2.** `(default) -> str | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | T
|
||||
|
||||
### _method_ `stop_propagation()` {#Matcher-stop-propagation}
|
||||
@@ -513,13 +453,11 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -529,13 +467,11 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -545,7 +481,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Permission](permission.md#Permission)
|
||||
|
||||
### _async method_ `resolve_reject()` {#Matcher-resolve-reject}
|
||||
@@ -555,25 +490,21 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -585,13 +516,11 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -603,7 +532,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `MatcherManager()` {#MatcherManager}
|
||||
@@ -625,7 +553,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- KeysView[int]
|
||||
|
||||
### _method_ `values()` {#MatcherManager-values}
|
||||
@@ -635,7 +562,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- ValuesView[list[type[[Matcher](#Matcher)]]]
|
||||
|
||||
### _method_ `items()` {#MatcherManager-items}
|
||||
@@ -645,7 +571,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- ItemsView[int, list[type[[Matcher](#Matcher)]]]
|
||||
|
||||
### _method_ `get(key, default=None)` {#MatcherManager-get}
|
||||
@@ -653,35 +578,27 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(key) -> list[type[Matcher]] | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]] | None
|
||||
|
||||
**2.** `(key, default) -> list[type[Matcher]] | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]] | T
|
||||
|
||||
### _method_ `pop(key)` {#MatcherManager-pop}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]]
|
||||
|
||||
### _method_ `popitem()` {#MatcherManager-popitem}
|
||||
@@ -691,7 +608,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[int, list[type[[Matcher](#Matcher)]]]
|
||||
|
||||
### _method_ `clear()` {#MatcherManager-clear}
|
||||
@@ -701,29 +617,24 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `update(m, /)` {#MatcherManager-update}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `setdefault(key, default)` {#MatcherManager-setdefault}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- `default` (list[type[[Matcher](#Matcher)]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]]
|
||||
|
||||
### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider}
|
||||
@@ -731,11 +642,9 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 设置事件响应器存储器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider}
|
||||
@@ -743,7 +652,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 事件响应器存储器基类
|
||||
|
||||
- **参数**
|
||||
|
||||
- `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器
|
||||
|
||||
## _var_ `matchers` {#matchers}
|
||||
|
@@ -20,11 +20,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_EventPreProcessor](typing.md#T-EventPreProcessor)
|
||||
|
||||
## _def_ `event_postprocessor(func)` {#event-postprocessor}
|
||||
@@ -36,11 +34,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_EventPostProcessor](typing.md#T-EventPostProcessor)
|
||||
|
||||
## _def_ `run_preprocessor(func)` {#run-preprocessor}
|
||||
@@ -52,11 +48,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次事件响应器运行前执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_RunPreProcessor](typing.md#T-RunPreProcessor)
|
||||
|
||||
## _def_ `run_postprocessor(func)` {#run-postprocessor}
|
||||
@@ -68,11 +62,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次事件响应器运行后执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_RunPostProcessor](typing.md#T-RunPostProcessor)
|
||||
|
||||
## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher}
|
||||
@@ -80,7 +72,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
- **说明:** 检查并运行事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
@@ -94,7 +85,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _async def_ `handle_event(bot, event)` {#handle-event}
|
||||
@@ -102,13 +92,11 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
- **说明:** 处理一个事件。调用该函数以实现分发事件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
|
@@ -14,11 +14,9 @@ description: nonebot.params 模块
|
||||
- **说明:** Arg 参数消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam}
|
||||
@@ -33,7 +31,6 @@ description: nonebot.params 模块
|
||||
留空则会根据参数名称获取。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `key` (str)
|
||||
@@ -47,11 +44,9 @@ description: nonebot.params 模块
|
||||
- **说明:** Arg 参数消息纯文本
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult}
|
||||
@@ -59,11 +54,9 @@ description: nonebot.params 模块
|
||||
- **说明:** `arg` prompt 发送结果
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `ArgStr(key=None)` {#ArgStr}
|
||||
@@ -71,11 +64,9 @@ description: nonebot.params 模块
|
||||
- **说明:** Arg 参数消息文本
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam}
|
||||
@@ -89,7 +80,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `checker` ([ModelField](compat.md#ModelField) | None)
|
||||
@@ -107,7 +97,6 @@ description: nonebot.params 模块
|
||||
本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -125,7 +114,6 @@ description: nonebot.params 模块
|
||||
本注入应该具有最高优先级,因此应该在其他参数之前检查。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `dependent` ([Dependent](dependencies/index.md#Dependent)[Any])
|
||||
@@ -139,7 +127,6 @@ description: nonebot.params 模块
|
||||
- **说明:** 子依赖装饰器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。
|
||||
|
||||
- `use_cache` (bool): 是否使用缓存。默认为 `True`。
|
||||
@@ -147,7 +134,6 @@ description: nonebot.params 模块
|
||||
- `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False`。
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
- **用法**
|
||||
@@ -180,7 +166,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `checker` ([ModelField](compat.md#ModelField) | None)
|
||||
@@ -198,7 +183,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -216,7 +200,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `checker` ([ModelField](compat.md#ModelField) | None)
|
||||
@@ -234,7 +217,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -250,7 +232,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `EventMessage()` {#EventMessage}
|
||||
@@ -262,7 +243,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `EventPlainText()` {#EventPlainText}
|
||||
@@ -274,7 +254,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `EventToMe()` {#EventToMe}
|
||||
@@ -286,7 +265,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `Command()` {#Command}
|
||||
@@ -298,7 +276,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[str, ...]
|
||||
|
||||
## _def_ `RawCommand()` {#RawCommand}
|
||||
@@ -310,7 +287,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `CommandArg()` {#CommandArg}
|
||||
@@ -322,7 +298,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `CommandStart()` {#CommandStart}
|
||||
@@ -334,7 +309,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `CommandWhitespace()` {#CommandWhitespace}
|
||||
@@ -346,7 +320,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `ShellCommandArgs()` {#ShellCommandArgs}
|
||||
@@ -358,7 +331,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `ShellCommandArgv()` {#ShellCommandArgv}
|
||||
@@ -370,7 +342,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `RegexMatched()` {#RegexMatched}
|
||||
@@ -382,7 +353,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Match[str]
|
||||
|
||||
## _def_ `RegexStr(*groups)` {#RegexStr}
|
||||
@@ -392,29 +362,21 @@ description: nonebot.params 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(group, /) -> str`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `group` (Literal[0])
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
**2.** `(group, /) -> str | Any`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `group` (str | int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | Any
|
||||
|
||||
**3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `group1` (str | int)
|
||||
|
||||
- `group2` (str | int)
|
||||
@@ -422,7 +384,6 @@ description: nonebot.params 模块
|
||||
- `*groups` (str | int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[str | Any, ...]
|
||||
|
||||
## _def_ `RegexGroup()` {#RegexGroup}
|
||||
@@ -434,7 +395,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Any, ...]
|
||||
|
||||
## _def_ `RegexDict()` {#RegexDict}
|
||||
@@ -446,7 +406,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `Startswith()` {#Startswith}
|
||||
@@ -458,7 +417,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Endswith()` {#Endswith}
|
||||
@@ -470,7 +428,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Fullmatch()` {#Fullmatch}
|
||||
@@ -482,7 +439,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Keyword()` {#Keyword}
|
||||
@@ -494,7 +450,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Received(id=None, default=None)` {#Received}
|
||||
@@ -502,13 +457,11 @@ description: nonebot.params 模块
|
||||
- **说明:** `receive` 事件参数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str | None)
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `LastReceived(default=None)` {#LastReceived}
|
||||
@@ -516,11 +469,9 @@ description: nonebot.params 模块
|
||||
- **说明:** `last_receive` 事件参数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult}
|
||||
@@ -528,11 +479,9 @@ description: nonebot.params 模块
|
||||
- **说明:** `receive` prompt 发送结果
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `PausePromptResult()` {#PausePromptResult}
|
||||
@@ -544,5 +493,4 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -22,7 +22,6 @@ description: nonebot.permission 模块
|
||||
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*users` (str)
|
||||
|
||||
- `perm` (Permission | None): 需要同时满足的权限
|
||||
@@ -30,7 +29,6 @@ description: nonebot.permission 模块
|
||||
- `user`: 会话白名单
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `Permission(*checkers)` {#Permission}
|
||||
@@ -42,7 +40,6 @@ description: nonebot.permission 模块
|
||||
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker
|
||||
|
||||
- **用法**
|
||||
@@ -64,7 +61,6 @@ description: nonebot.permission 模块
|
||||
- **说明:** 检查是否满足某个权限。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
@@ -74,7 +70,6 @@ description: nonebot.permission 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `User(users, perm=None)` {#User}
|
||||
@@ -82,7 +77,6 @@ description: nonebot.permission 模块
|
||||
- **说明:** 检查当前事件是否属于指定会话。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `users` (tuple[str, ...]): 会话 ID 元组
|
||||
|
||||
- `perm` (Permission | None): 需同时满足的权限
|
||||
@@ -96,13 +90,11 @@ description: nonebot.permission 模块
|
||||
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
|
||||
- `perm` (Permission | None): 需同时满足的权限
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission}
|
||||
@@ -114,13 +106,11 @@ description: nonebot.permission 模块
|
||||
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*users` (str): 会话白名单
|
||||
|
||||
- `perm` (Permission | None): 需同时满足的权限
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
## _class_ `Message(<auto>)` {#Message}
|
||||
|
@@ -51,11 +51,9 @@ description: nonebot.plugin 模块
|
||||
如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名`。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name}
|
||||
@@ -67,11 +65,9 @@ description: nonebot.plugin 模块
|
||||
如果提供的模块名为某个插件的子模块,同样会返回该插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `get_loaded_plugins()` {#get-loaded-plugins}
|
||||
@@ -83,7 +79,6 @@ description: nonebot.plugin 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `get_available_plugin_names()` {#get-available-plugin-names}
|
||||
@@ -95,7 +90,6 @@ description: nonebot.plugin 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[str]
|
||||
|
||||
## _def_ `get_plugin_config(config)` {#get-plugin-config}
|
||||
@@ -103,9 +97,7 @@ description: nonebot.plugin 模块
|
||||
- **说明:** 从全局配置获取当前插件需要的配置项。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `config` (type[C])
|
||||
|
||||
- **返回**
|
||||
|
||||
- C
|
||||
|
@@ -14,11 +14,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)`
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `load_plugins(*plugin_dir)` {#load-plugins}
|
||||
@@ -26,11 +24,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*plugin_dir` (str): 文件夹路径
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins}
|
||||
@@ -38,13 +34,11 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_path` (Iterable[str]): 指定插件集合
|
||||
|
||||
- `plugin_dir` (Iterable[str]): 指定文件夹路径集合
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json}
|
||||
@@ -52,13 +46,11 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `file_path` (str): 指定 json 文件路径
|
||||
|
||||
- `encoding` (str): 指定 json 文件编码
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
- **用法**
|
||||
@@ -79,13 +71,11 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `file_path` (str): 指定 toml 文件路径
|
||||
|
||||
- `encoding` (str): 指定 toml 文件编码
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
- **用法**
|
||||
@@ -105,11 +95,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入 NoneBot 内置插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins}
|
||||
@@ -117,11 +105,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入多个 NoneBot 内置插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*plugins` (str): 插件名称列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `require(name)` {#require}
|
||||
@@ -129,15 +115,12 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 声明依赖插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。
|
||||
|
||||
- **返回**
|
||||
|
||||
- ModuleType
|
||||
|
||||
- **异常**
|
||||
|
||||
- RuntimeError: 插件无法加载
|
||||
|
||||
## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters}
|
||||
@@ -149,15 +132,12 @@ description: nonebot.plugin.load 模块
|
||||
如果传入了多个插件名称,返回值会自动取交集。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*names` (str): 插件名称列表。
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[str] | None
|
||||
|
||||
- **异常**
|
||||
|
||||
- RuntimeError: 插件未加载
|
||||
|
||||
- ValueError: 插件缺少元数据
|
||||
|
@@ -16,7 +16,6 @@ description: nonebot.plugin.manager 模块
|
||||
- **说明:** 插件管理器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `plugins` (Iterable[str] | None): 独立插件模块名集合。
|
||||
|
||||
- `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。
|
||||
@@ -54,11 +53,9 @@ description: nonebot.plugin.manager 模块
|
||||
可以使用完整插件模块名或者插件标识符加载。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名称或插件标识符。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins}
|
||||
@@ -70,7 +67,6 @@ description: nonebot.plugin.manager 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _class_ `PluginFinder(<auto>)` {#PluginFinder}
|
||||
@@ -82,7 +78,6 @@ description: nonebot.plugin.manager 模块
|
||||
### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `fullname` (str)
|
||||
|
||||
- `path` (Sequence[str] | None)
|
||||
@@ -90,13 +85,11 @@ description: nonebot.plugin.manager 模块
|
||||
- `target` (ModuleType | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `manager` (PluginManager)
|
||||
|
||||
- `fullname` (str)
|
||||
@@ -106,19 +99,15 @@ description: nonebot.plugin.manager 模块
|
||||
### _method_ `create_module(spec)` {#PluginLoader-create-module}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `spec`
|
||||
|
||||
- **返回**
|
||||
|
||||
- ModuleType | None
|
||||
|
||||
### _method_ `exec_module(module)` {#PluginLoader-exec-module}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module` (ModuleType)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
@@ -80,7 +80,6 @@ description: nonebot.plugin.model 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[type[[Adapter](../adapters/index.md#Adapter)]] | None
|
||||
|
||||
## _class_ `Plugin(<auto>)` {#Plugin}
|
||||
|
@@ -14,11 +14,9 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 存储一个事件响应器到插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin}
|
||||
@@ -30,11 +28,9 @@ description: nonebot.plugin.on 模块
|
||||
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `depth` (int): 调用栈深度
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `get_matcher_module(depth=...)` {#get-matcher-module}
|
||||
@@ -46,11 +42,9 @@ description: nonebot.plugin.on 模块
|
||||
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `depth` (int): 调用栈深度
|
||||
|
||||
- **返回**
|
||||
|
||||
- ModuleType | None
|
||||
|
||||
## _def_ `get_matcher_source(depth=...)` {#get-matcher-source}
|
||||
@@ -58,11 +52,9 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 获取事件响应器定义所在源码信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `depth` (int): 调用栈深度
|
||||
|
||||
- **返回**
|
||||
|
||||
- MatcherSource | None
|
||||
|
||||
## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on}
|
||||
@@ -70,7 +62,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个基础事件响应器,可自定义类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str): 事件响应器类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -90,7 +81,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent}
|
||||
@@ -98,7 +88,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个元事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -116,7 +105,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message}
|
||||
@@ -124,7 +112,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -142,7 +129,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice}
|
||||
@@ -150,7 +136,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个通知事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -168,7 +153,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request}
|
||||
@@ -176,7 +160,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个请求事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -194,7 +177,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith}
|
||||
@@ -202,7 +184,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -224,7 +205,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith}
|
||||
@@ -232,7 +212,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息结尾内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -254,7 +233,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch}
|
||||
@@ -262,7 +240,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -284,7 +261,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword}
|
||||
@@ -292,7 +268,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `keywords` (set[str]): 关键词列表
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -312,7 +287,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command}
|
||||
@@ -324,7 +298,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -348,7 +321,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command}
|
||||
@@ -363,7 +335,6 @@ description: nonebot.plugin.on 模块
|
||||
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -387,7 +358,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex}
|
||||
@@ -399,7 +369,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `pattern` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则匹配标志
|
||||
@@ -421,7 +390,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type}
|
||||
@@ -429,7 +397,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -449,13 +416,11 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...])
|
||||
|
||||
- `prefix_aliases` (bool)
|
||||
@@ -481,7 +446,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -505,7 +469,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command}
|
||||
@@ -513,7 +476,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -537,13 +499,11 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str)
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None)
|
||||
@@ -567,7 +527,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个基础事件响应器,可自定义类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str): 事件响应器类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -587,7 +546,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent}
|
||||
@@ -595,7 +553,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个元事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -613,7 +570,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message}
|
||||
@@ -621,7 +577,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -639,7 +594,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice}
|
||||
@@ -647,7 +601,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个通知事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -665,7 +618,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request}
|
||||
@@ -673,7 +625,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个请求事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -691,7 +642,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith}
|
||||
@@ -699,7 +649,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -721,7 +670,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith}
|
||||
@@ -729,7 +677,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息结尾内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -751,7 +698,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch}
|
||||
@@ -759,7 +705,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -781,7 +726,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword}
|
||||
@@ -789,7 +733,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `keywords` (set[str]): 关键词列表
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -809,7 +752,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command}
|
||||
@@ -821,7 +763,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
@@ -845,7 +786,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command}
|
||||
@@ -860,7 +800,6 @@ description: nonebot.plugin.on 模块
|
||||
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
@@ -884,7 +823,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex}
|
||||
@@ -896,7 +834,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `pattern` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则匹配标志
|
||||
@@ -918,7 +855,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type}
|
||||
@@ -926,7 +862,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -946,5 +881,4 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
@@ -22,7 +22,6 @@ description: nonebot.rule 模块
|
||||
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker
|
||||
|
||||
- **用法**
|
||||
@@ -44,7 +43,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查是否符合所有规则
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
@@ -56,7 +54,6 @@ description: nonebot.rule 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT}
|
||||
@@ -78,7 +75,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否以指定字符串开头。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (tuple[str, ...]): 指定消息开头字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -88,13 +84,11 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配消息纯文本开头。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule}
|
||||
@@ -102,7 +96,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否以指定字符串结尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (tuple[str, ...]): 指定消息结尾字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -112,13 +105,11 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配消息纯文本结尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule}
|
||||
@@ -126,7 +117,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否与指定字符串全匹配。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (tuple[str, ...]): 指定消息全匹配字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -136,13 +126,11 @@ description: nonebot.rule 模块
|
||||
- **说明:** 完全匹配消息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `KeywordsRule(*keywords)` {#KeywordsRule}
|
||||
@@ -150,7 +138,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否包含指定关键字。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*keywords` (str): 指定关键字元组
|
||||
|
||||
## _def_ `keyword(*keywords)` {#keyword}
|
||||
@@ -158,11 +145,9 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配消息纯文本关键词。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*keywords` (str): 指定关键字元组
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule}
|
||||
@@ -170,7 +155,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息是否为指定命令。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表
|
||||
|
||||
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
|
||||
@@ -189,13 +173,11 @@ description: nonebot.rule 模块
|
||||
通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
|
||||
|
||||
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
- **用法**
|
||||
@@ -231,37 +213,28 @@ description: nonebot.rule 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
|
||||
|
||||
- `namespace` (None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
|
||||
|
||||
**2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
|
||||
|
||||
- `namespace` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
|
||||
|
||||
**3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `namespace` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
|
||||
|
||||
## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule}
|
||||
@@ -269,7 +242,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息是否为指定 shell 命令。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表
|
||||
|
||||
- `parser` (ArgumentParser | None): 可选参数解析器
|
||||
@@ -298,13 +270,11 @@ description: nonebot.rule 模块
|
||||
:::
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
|
||||
|
||||
- `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
- **用法**
|
||||
@@ -330,7 +300,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息字符串是否符合指定正则表达式。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `regex` (str): 正则表达式
|
||||
|
||||
- `flags` (int): 正则表达式标记
|
||||
@@ -346,13 +315,11 @@ description: nonebot.rule 模块
|
||||
通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `regex` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则表达式标记
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
:::tip 提示
|
||||
@@ -380,7 +347,6 @@ description: nonebot.rule 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `IsTypeRule(*types)` {#IsTypeRule}
|
||||
@@ -388,7 +354,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查事件类型是否为指定类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (type[[Event](adapters/index.md#Event)])
|
||||
|
||||
## _def_ `is_type(*types)` {#is-type}
|
||||
@@ -396,9 +361,7 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配事件类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (type[[Event](adapters/index.md#Event)]): 事件类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
@@ -19,31 +19,25 @@ description: nonebot.typing 模块
|
||||
- **说明:** 标记一个方法为父类 interface 的 implement
|
||||
|
||||
- **参数**
|
||||
|
||||
- `InterfaceClass` (object)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _def_ `type_has_args(type_)` {#type-has-args}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `origin_is_union(origin)` {#origin-is-union}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `origin` (type[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `origin_is_literal(origin)` {#origin-is-literal}
|
||||
@@ -51,11 +45,9 @@ description: nonebot.typing 模块
|
||||
- **说明:** 判断是否是 Literal 类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `origin` (type[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `all_literal_values(type_)` {#all-literal-values}
|
||||
@@ -63,11 +55,9 @@ description: nonebot.typing 模块
|
||||
- **说明:** 获取 Literal 类型包含的所有值
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[Any]
|
||||
|
||||
## _def_ `origin_is_annotated(origin)` {#origin-is-annotated}
|
||||
@@ -75,11 +65,9 @@ description: nonebot.typing 模块
|
||||
- **说明:** 判断是否是 Annotated 类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `origin` (type[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_none_type(type_)` {#is-none-type}
|
||||
@@ -87,17 +75,14 @@ description: nonebot.typing 模块
|
||||
- **说明:** 判断是否是 None 类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `ref` (ForwardRef)
|
||||
|
||||
- `globalns` (dict[str, Any])
|
||||
@@ -105,7 +90,6 @@ description: nonebot.typing 模块
|
||||
- `localns` (dict[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _class_ `StateFlag(<auto>)` {#StateFlag}
|
||||
@@ -129,7 +113,6 @@ description: nonebot.typing 模块
|
||||
Bot 连接建立时钩子函数
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- DefaultParam: 带有默认值的参数
|
||||
@@ -143,7 +126,6 @@ description: nonebot.typing 模块
|
||||
Bot 连接断开时钩子函数
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- DefaultParam: 带有默认值的参数
|
||||
@@ -169,7 +151,6 @@ description: nonebot.typing 模块
|
||||
事件预处理函数 EventPreProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -185,7 +166,6 @@ description: nonebot.typing 模块
|
||||
事件后处理函数 EventPostProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -201,7 +181,6 @@ description: nonebot.typing 模块
|
||||
事件响应器运行前预处理函数 RunPreProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -218,7 +197,6 @@ description: nonebot.typing 模块
|
||||
事件响应器运行后后处理函数 RunPostProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -236,7 +214,6 @@ description: nonebot.typing 模块
|
||||
RuleChecker 即判断是否响应事件的处理函数。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -252,7 +229,6 @@ description: nonebot.typing 模块
|
||||
PermissionChecker 即判断事件是否满足权限的处理函数。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -273,7 +249,6 @@ description: nonebot.typing 模块
|
||||
TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message`。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -290,7 +265,6 @@ description: nonebot.typing 模块
|
||||
PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
|
@@ -18,11 +18,9 @@ description: nonebot.utils 模块
|
||||
参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color)
|
||||
|
||||
- **参数**
|
||||
|
||||
- `s` (str): 需要转义的字符串
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update}
|
||||
@@ -30,13 +28,11 @@ description: nonebot.utils 模块
|
||||
- **说明:** 深度更新合并字典
|
||||
|
||||
- **参数**
|
||||
|
||||
- `mapping` (dict[K, Any])
|
||||
|
||||
- `*updating_mappings` (dict[K, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[K, Any]
|
||||
|
||||
## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass}
|
||||
@@ -44,13 +40,11 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cls` (Any)
|
||||
|
||||
- `class_or_tuple` (type[Any] | tuple[type[Any], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass}
|
||||
@@ -60,7 +54,6 @@ description: nonebot.utils 模块
|
||||
检查 cls 是否是 class_or_tuple 中的一个类型子类。
|
||||
|
||||
特别的:
|
||||
|
||||
- 如果 cls 是 `typing.Union` 或 `types.UnionType` 类型,
|
||||
则会检查其中的所有类型是否是 class_or_tuple 中一个类型的子类或 None。
|
||||
- 如果 cls 是 `typing.Literal` 类型,
|
||||
@@ -70,13 +63,11 @@ description: nonebot.utils 模块
|
||||
是否是 class_or_tuple 中一个类型的子类或 None。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cls` (Any)
|
||||
|
||||
- `class_or_tuple` (type[Any] | tuple[type[Any], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `type_is_complex(type_)` {#type-is-complex}
|
||||
@@ -84,11 +75,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 type\_ 是否是复杂类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable}
|
||||
@@ -96,11 +85,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 call 是否是一个 callable 协程函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_gen_callable(call)` {#is-gen-callable}
|
||||
@@ -108,11 +95,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 call 是否是一个生成器函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable}
|
||||
@@ -120,11 +105,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 call 是否是一个异步生成器函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `run_sync(call)` {#run-sync}
|
||||
@@ -132,11 +115,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 一个用于包装 sync function 为 async function 的装饰器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((P) -> R): 被装饰的同步函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- (P) -> Coroutine[None, None, R]
|
||||
|
||||
## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager}
|
||||
@@ -144,11 +125,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cm` (AbstractContextManager[T])
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[T, None]
|
||||
|
||||
## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch}
|
||||
@@ -158,9 +137,7 @@ description: nonebot.utils 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(coro, exc, return_on_err=None) -> T | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro` (Coroutine[Any, Any, T])
|
||||
|
||||
- `exc` (tuple[type[Exception], ...])
|
||||
@@ -168,13 +145,10 @@ description: nonebot.utils 模块
|
||||
- `return_on_err` (None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T | None
|
||||
|
||||
**2.** `(coro, exc, return_on_err) -> T | R`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro` (Coroutine[Any, Any, T])
|
||||
|
||||
- `exc` (tuple[type[Exception], ...])
|
||||
@@ -182,11 +156,9 @@ description: nonebot.utils 模块
|
||||
- `return_on_err` (R)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T | R
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro`: 要运行的协程
|
||||
|
||||
- `exc`: 要捕获的异常
|
||||
@@ -202,21 +174,17 @@ description: nonebot.utils 模块
|
||||
- **说明:** 运行协程并在取消时屏蔽取消异常。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro` (Coroutine[Any, Any, T]): 要运行的协程
|
||||
|
||||
- **返回**
|
||||
|
||||
- T: 协程的返回值
|
||||
|
||||
## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `exc_group` (BaseExceptionGroup[E])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Generator[E, None, None]
|
||||
|
||||
## _def_ `get_name(obj)` {#get-name}
|
||||
@@ -224,11 +192,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 获取对象的名称
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `path_to_module_name(path)` {#path-to-module-name}
|
||||
@@ -236,11 +202,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 转换路径为模块名
|
||||
|
||||
- **参数**
|
||||
|
||||
- `path` (Path)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation}
|
||||
@@ -248,7 +212,6 @@ description: nonebot.utils 模块
|
||||
- **说明:** 解析并导入点分表示法的对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj_str` (str)
|
||||
|
||||
- `default_attr` (str)
|
||||
@@ -256,7 +219,6 @@ description: nonebot.utils 模块
|
||||
- `default_prefix` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _class_ `classproperty(func)` {#classproperty}
|
||||
@@ -264,7 +226,6 @@ description: nonebot.utils 模块
|
||||
- **说明:** 类属性装饰器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ((Any) -> T)
|
||||
|
||||
## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder}
|
||||
@@ -278,11 +239,9 @@ description: nonebot.utils 模块
|
||||
### _method_ `default(o)` {#DataclassEncoder-default}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `o`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _def_ `logger_wrapper(logger_name)` {#logger-wrapper}
|
||||
@@ -290,15 +249,12 @@ description: nonebot.utils 模块
|
||||
- **说明:** 用于打印 adapter 的日志。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `logger_name` (str): adapter 的名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped: 日志记录函数
|
||||
|
||||
日志记录函数的参数:
|
||||
|
||||
- level: 日志等级
|
||||
- message: 日志信息
|
||||
- exception: 异常信息
|
||||
|
@@ -278,7 +278,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
|
||||
`Arparma` 有如下属性:
|
||||
|
||||
- 调试类
|
||||
|
||||
- matched: 是否匹配成功
|
||||
- error_data: 解析失败时剩余的数据
|
||||
- error_info: 解析失败时的异常内容
|
||||
|
@@ -40,7 +40,7 @@ async def handle_function():
|
||||
|
||||
### 处理近似事件
|
||||
|
||||
对于一系列**差异不大**的事件,我们往往具有相同的处理逻辑。这时,我们不希望将相同的逻辑编写两遍,而应该复用代码,以实现在同一个事件处理函数中处理多个近似事件。我们可以使用[事件重载](../advanced/dependency.mdx#Event)的特性来实现这一功能。例如:
|
||||
对于一系列**差异不大**的事件,我们往往具有相同的处理逻辑。这时,我们不希望将相同的逻辑编写两遍,而应该复用代码,以实现在同一个事件处理函数中处理多个近似事件。我们可以使用[事件重载](../advanced/dependency.mdx#event)的特性来实现这一功能。例如:
|
||||
|
||||
<Tabs groupId="python">
|
||||
<TabItem value="3.10" label="Python 3.10+" default>
|
||||
|
@@ -155,7 +155,6 @@ async def test_example(app: App):
|
||||
1. `should_call_send`
|
||||
|
||||
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
|
||||
|
||||
- `event`:回复的目标事件。
|
||||
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
|
||||
- `result`:send 的返回值,将会返回给插件。
|
||||
@@ -163,8 +162,7 @@ async def test_example(app: App):
|
||||
- `**kwargs`:send 方法的额外参数。
|
||||
|
||||
2. `should_call_api`
|
||||
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-API)进行的操作。`should_call_api` 有四个参数:
|
||||
|
||||
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
|
||||
- `api`:API 名称。
|
||||
- `data`:预期的请求数据。
|
||||
- `result`:call_api 的返回值,将会返回给插件。
|
||||
|
@@ -20,7 +20,6 @@ description: nonebot.adapters 模块
|
||||
通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例
|
||||
|
||||
- `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数
|
||||
@@ -46,7 +45,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _property_ `config` {#Adapter-config}
|
||||
@@ -64,11 +62,9 @@ description: nonebot.adapters 模块
|
||||
当有新的 [Bot](#Bot) 实例连接建立成功时调用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect}
|
||||
@@ -80,11 +76,9 @@ description: nonebot.adapters 模块
|
||||
当有 [Bot](#Bot) 实例连接断开时调用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server}
|
||||
@@ -92,11 +86,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 设置一个 HTTP 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server}
|
||||
@@ -104,11 +96,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 设置一个 WebSocket 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `request(setup)` {#Adapter-request}
|
||||
@@ -116,11 +106,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 进行一个 HTTP 客户端请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](../drivers/index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](../drivers/index.md#Response)
|
||||
|
||||
### _method_ `websocket(setup)` {#Adapter-websocket}
|
||||
@@ -128,21 +116,17 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 建立一个 WebSocket 客户端连接请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](../drivers/index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None]
|
||||
|
||||
### _method_ `on_ready(func)` {#Adapter-on-ready}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
## _abstract class_ `Bot(adapter, self_id)` {#Bot}
|
||||
@@ -154,7 +138,6 @@ description: nonebot.adapters 模块
|
||||
用于处理上报消息,并提供 API 调用接口。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter` ([Adapter](#Adapter)): 协议适配器实例
|
||||
|
||||
- `self_id` (str): 机器人 ID
|
||||
@@ -188,13 +171,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
|
||||
|
||||
- **参数**
|
||||
|
||||
- `api` (str): API 名称
|
||||
|
||||
- `**data` (Any): API 数据
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
- **用法**
|
||||
@@ -209,7 +190,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 调用机器人基础发送消息接口
|
||||
|
||||
- **参数**
|
||||
|
||||
- `event` ([Event](#Event)): 上报事件
|
||||
|
||||
- `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息
|
||||
@@ -217,7 +197,6 @@ description: nonebot.adapters 模块
|
||||
- `**kwargs` (Any): 任意额外参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api}
|
||||
@@ -227,17 +206,14 @@ description: nonebot.adapters 模块
|
||||
调用 api 预处理。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前 bot 对象
|
||||
- api: 调用的 api 名称
|
||||
- data: api 调用的参数字典
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_CallingAPIHook](../typing.md#T-CallingAPIHook)
|
||||
|
||||
### _classmethod_ `on_called_api(func)` {#Bot-on-called-api}
|
||||
@@ -247,7 +223,6 @@ description: nonebot.adapters 模块
|
||||
调用 api 后处理。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前 bot 对象
|
||||
- exception: 调用 api 时发生的错误
|
||||
- api: 调用的 api 名称
|
||||
@@ -255,11 +230,9 @@ description: nonebot.adapters 模块
|
||||
- result: api 调用的返回
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_CalledAPIHook](../typing.md#T-CalledAPIHook)
|
||||
|
||||
## _abstract class_ `Event(<auto>)` {#Event}
|
||||
@@ -279,7 +252,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_event_name()` {#Event-get-event-name}
|
||||
@@ -291,7 +263,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_event_description()` {#Event-get-event-description}
|
||||
@@ -303,7 +274,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _method_ `get_log_string()` {#Event-get-log-string}
|
||||
@@ -320,11 +290,9 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
- **异常**
|
||||
|
||||
- NoLogException: 希望 NoneBot 隐藏该事件日志
|
||||
|
||||
### _abstract method_ `get_user_id()` {#Event-get-user-id}
|
||||
@@ -336,7 +304,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_session_id()` {#Event-get-session-id}
|
||||
@@ -348,7 +315,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_message()` {#Event-get-message}
|
||||
@@ -360,7 +326,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](#Message)
|
||||
|
||||
### _method_ `get_plaintext()` {#Event-get-plaintext}
|
||||
@@ -376,7 +341,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `is_tome()` {#Event-is-tome}
|
||||
@@ -388,7 +352,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _abstract class_ `Message(<auto>)` {#Message}
|
||||
@@ -396,7 +359,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 消息序列
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message`: 消息内容
|
||||
|
||||
### _classmethod_ `template(format_string)` {#Message-template}
|
||||
@@ -410,11 +372,9 @@ description: nonebot.adapters 模块
|
||||
可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `format_string` (str | TM): 格式化模板
|
||||
|
||||
- **返回**
|
||||
|
||||
- [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器
|
||||
|
||||
### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class}
|
||||
@@ -426,7 +386,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[TMS]
|
||||
|
||||
### _abstract staticmethod_ `_construct(msg)` {#Message--construct}
|
||||
@@ -434,11 +393,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 构造消息数组
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Iterable[TMS]
|
||||
|
||||
### _method_ `__getitem__(args)` {#Message---getitem--}
|
||||
@@ -446,53 +403,38 @@ description: nonebot.adapters 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (str): 消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 所有类型为 `args` 的消息段
|
||||
|
||||
**2.** `(args) -> TMS`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (tuple[str, int]): 消息段类型和索引
|
||||
|
||||
- **返回**
|
||||
|
||||
- TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个
|
||||
|
||||
**3.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (tuple[str, slice]): 消息段类型和切片
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 类型为 `args[0]` 的消息段切片 `args[1]`
|
||||
|
||||
**4.** `(args) -> TMS`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (int): 索引
|
||||
|
||||
- **返回**
|
||||
|
||||
- TMS: 第 `args` 个消息段
|
||||
|
||||
**5.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (slice): 切片
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 消息切片 `args`
|
||||
|
||||
### _method_ `__contains__(value)` {#Message---contains--}
|
||||
@@ -500,11 +442,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 检查消息段是否存在
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 消息内是否存在给定消息段或给定类型的消息段
|
||||
|
||||
### _method_ `has(value)` {#Message-has}
|
||||
@@ -512,11 +452,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 与 [`__contains__`](#Message---contains--) 相同
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
### _method_ `index(value, *args)` {#Message-index}
|
||||
@@ -524,7 +462,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 索引消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或者消息段类型
|
||||
|
||||
- `*args` (SupportsIndex)
|
||||
@@ -532,11 +469,9 @@ description: nonebot.adapters 模块
|
||||
- `arg`: start 与 end
|
||||
|
||||
- **返回**
|
||||
|
||||
- int: 索引 index
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 消息段不存在
|
||||
|
||||
### _method_ `get(type_, count=None)` {#Message-get}
|
||||
@@ -544,13 +479,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 获取指定类型的消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (str): 消息段类型
|
||||
|
||||
- `count` (int | None): 获取个数
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 构建的新消息
|
||||
|
||||
### _method_ `count(value)` {#Message-count}
|
||||
@@ -558,11 +491,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 计算指定消息段的个数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- int: 个数
|
||||
|
||||
### _method_ `only(value)` {#Message-only}
|
||||
@@ -570,11 +501,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 检查消息中是否仅包含指定消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 指定消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否仅包含指定消息段
|
||||
|
||||
### _method_ `append(obj)` {#Message-append}
|
||||
@@ -582,11 +511,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 添加一个消息段到消息数组末尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (str | TMS): 要添加的消息段
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `extend(obj)` {#Message-extend}
|
||||
@@ -594,11 +521,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (Self | Iterable[TMS]): 要添加的消息数组
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `join(iterable)` {#Message-join}
|
||||
@@ -606,11 +531,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 将多个消息连接并将自身作为分割
|
||||
|
||||
- **参数**
|
||||
|
||||
- `iterable` (Iterable[TMS | Self]): 要连接的消息
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 连接后的消息
|
||||
|
||||
### _method_ `copy()` {#Message-copy}
|
||||
@@ -622,7 +545,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `include(*types)` {#Message-include}
|
||||
@@ -630,11 +552,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 过滤消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (str): 包含的消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 新构造的消息
|
||||
|
||||
### _method_ `exclude(*types)` {#Message-exclude}
|
||||
@@ -642,11 +562,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 过滤消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (str): 不包含的消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 新构造的消息
|
||||
|
||||
### _method_ `extract_plain_text()` {#Message-extract-plain-text}
|
||||
@@ -658,7 +576,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment}
|
||||
@@ -690,7 +607,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[TM]
|
||||
|
||||
### _abstract method_ `__str__()` {#MessageSegment---str--}
|
||||
@@ -702,29 +618,24 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _method_ `__add__(other)` {#MessageSegment---add--}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `other` (str | TMS | Iterable[TMS])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TM
|
||||
|
||||
### _method_ `get(key, default=None)` {#MessageSegment-get}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `keys()` {#MessageSegment-keys}
|
||||
@@ -734,7 +645,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `values()` {#MessageSegment-values}
|
||||
@@ -744,7 +654,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `items()` {#MessageSegment-items}
|
||||
@@ -754,17 +663,14 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `join(iterable)` {#MessageSegment-join}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `iterable` (Iterable[TMS | TM])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TM
|
||||
|
||||
### _method_ `copy()` {#MessageSegment-copy}
|
||||
@@ -774,7 +680,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _abstract method_ `is_text()` {#MessageSegment-is-text}
|
||||
@@ -786,7 +691,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate}
|
||||
@@ -794,7 +698,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 消息模板格式化实现类。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `template` (str | TM): 模板
|
||||
|
||||
- `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str`
|
||||
@@ -804,13 +707,11 @@ description: nonebot.adapters 模块
|
||||
### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `spec` (FormatSpecFunc_T)
|
||||
|
||||
- `name` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- FormatSpecFunc_T
|
||||
|
||||
### _method_ `format(*args, **kwargs)` {#MessageTemplate-format}
|
||||
@@ -818,13 +719,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 根据传入参数和模板生成消息对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `format_map(mapping)` {#MessageTemplate-format-map}
|
||||
@@ -832,17 +731,14 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用
|
||||
|
||||
- **参数**
|
||||
|
||||
- `mapping` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `format_string` (str)
|
||||
|
||||
- `args` (Sequence[Any])
|
||||
@@ -850,13 +746,11 @@ description: nonebot.adapters 模块
|
||||
- `kwargs` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field_name` (str)
|
||||
|
||||
- `args` (Sequence[Any])
|
||||
@@ -864,17 +758,14 @@ description: nonebot.adapters 模块
|
||||
- `kwargs` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Any, int | str]
|
||||
|
||||
### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- `format_spec` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -36,7 +36,6 @@ description: nonebot.compat 模块
|
||||
- **说明:** FieldInfo class with extra property for compatibility with pydantic v1
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- `**kwargs` (Any)
|
||||
@@ -82,7 +81,6 @@ description: nonebot.compat 模块
|
||||
- **说明:** Construct a ModelField from given infos.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `annotation` (Any)
|
||||
@@ -90,7 +88,6 @@ description: nonebot.compat 模块
|
||||
- `field_info` (FieldInfo | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `get_default()` {#ModelField-get-default}
|
||||
@@ -102,7 +99,6 @@ description: nonebot.compat 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _method_ `validate_value(value)` {#ModelField-validate-value}
|
||||
@@ -110,11 +106,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate the value pass to the field.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `extract_field_info(field_info)` {#extract-field-info}
|
||||
@@ -122,11 +116,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get FieldInfo init kwargs from a FieldInfo instance.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field_info` (BaseFieldInfo)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `model_fields(model)` {#model-fields}
|
||||
@@ -134,11 +126,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get field list of a model.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (type[BaseModel])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[ModelField]
|
||||
|
||||
## _def_ `model_config(model)` {#model-config}
|
||||
@@ -146,17 +136,14 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get config of a model.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (type[BaseModel])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (BaseModel)
|
||||
|
||||
- `include` (set[str] | None)
|
||||
@@ -172,7 +159,6 @@ description: nonebot.compat 模块
|
||||
- `exclude_none` (bool)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `type_validate_python(type_, data)` {#type-validate-python}
|
||||
@@ -180,13 +166,11 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate data with given type.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[T])
|
||||
|
||||
- `data` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T
|
||||
|
||||
## _def_ `type_validate_json(type_, data)` {#type-validate-json}
|
||||
@@ -194,13 +178,11 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate JSON with given type.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[T])
|
||||
|
||||
- `data` (str | bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T
|
||||
|
||||
## _def_ `custom_validation(class_)` {#custom-validation}
|
||||
@@ -208,9 +190,7 @@ description: nonebot.compat 模块
|
||||
- **说明:** Use pydantic v1 like validator generator in pydantic v2
|
||||
|
||||
- **参数**
|
||||
|
||||
- `class_` (type[CVC])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[CVC]
|
||||
|
@@ -24,7 +24,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
|
||||
将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None)
|
||||
|
||||
- `_env_file_encoding` (str | None)
|
||||
@@ -55,7 +54,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
|
||||
配置方法参考: [配置](https://nonebot.dev/docs/appendices/config)
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None)
|
||||
|
||||
- `_env_file_encoding` (str | None)
|
||||
|
@@ -18,7 +18,6 @@ description: nonebot.dependencies 模块
|
||||
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -30,7 +29,6 @@ description: nonebot.dependencies 模块
|
||||
- **说明:** 依赖注入容器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call`: 依赖注入的可调用对象,可以是任何 Callable 对象
|
||||
|
||||
- `pre_checkers`: 依赖注入解析前的参数检查
|
||||
@@ -44,31 +42,26 @@ description: nonebot.dependencies 模块
|
||||
### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` (\_DependentCallable[R])
|
||||
|
||||
- `allow_types` (tuple[type[Param], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[[ModelField](../compat.md#ModelField), ...]
|
||||
|
||||
### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `parameterless` (tuple[Any, ...])
|
||||
|
||||
- `allow_types` (tuple[type[Param], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Param, ...]
|
||||
|
||||
### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` (\_DependentCallable[R])
|
||||
|
||||
- `parameterless` (Iterable[Any] | None)
|
||||
@@ -76,25 +69,20 @@ description: nonebot.dependencies 模块
|
||||
- `allow_types` (Iterable[type[Param]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Dependent[R]
|
||||
|
||||
### _async method_ `check(**params)` {#Dependent-check}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `**params` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `solve(**params)` {#Dependent-solve}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `**params` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
@@ -12,11 +12,9 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 获取可调用对象签名
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- inspect.Signature
|
||||
|
||||
## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation}
|
||||
@@ -24,13 +22,11 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 获取参数的类型注解
|
||||
|
||||
- **参数**
|
||||
|
||||
- `param` (inspect.Parameter)
|
||||
|
||||
- `globalns` (dict[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `check_field_type(field, value)` {#check-field-type}
|
||||
@@ -38,11 +34,9 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 检查字段类型是否匹配
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field` ([ModelField](../compat.md#ModelField))
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -22,7 +22,6 @@ pip install nonebot2[aiohttp]
|
||||
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -38,11 +37,9 @@ pip install nonebot2[aiohttp]
|
||||
### _async method_ `request(setup)` {#Session-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _async method_ `setup()` {#Session-setup}
|
||||
@@ -52,7 +49,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close()` {#Session-close}
|
||||
@@ -62,7 +58,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -76,27 +71,22 @@ pip install nonebot2[aiohttp]
|
||||
### _async method_ `request(setup)` {#Mixin-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `websocket(setup)` {#Mixin-websocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](index.md#WebSocket), None]
|
||||
|
||||
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -110,7 +100,6 @@ pip install nonebot2[aiohttp]
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Session
|
||||
|
||||
## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket}
|
||||
@@ -118,7 +107,6 @@ pip install nonebot2[aiohttp]
|
||||
- **说明:** AIOHTTP Websocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` ([Request](index.md#Request))
|
||||
|
||||
- `session` (aiohttp.ClientSession)
|
||||
@@ -132,19 +120,16 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -154,7 +139,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -164,7 +148,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -174,33 +157,27 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -92,7 +92,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** FastAPI 驱动框架。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` (NoneBotConfig)
|
||||
@@ -124,21 +123,17 @@ pip install nonebot2[fastapi]
|
||||
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
|
||||
@@ -146,7 +141,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** 使用 `uvicorn` 启动 FastAPI
|
||||
|
||||
- **参数**
|
||||
|
||||
- `host` (str | None)
|
||||
|
||||
- `port` (int | None)
|
||||
@@ -158,7 +152,6 @@ pip install nonebot2[fastapi]
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket}
|
||||
@@ -166,7 +159,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** FastAPI WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (BaseRequest)
|
||||
|
||||
- `websocket` ([WebSocket](index.md#WebSocket))
|
||||
@@ -178,19 +170,16 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `receive()` {#FastAPIWebSocket-receive}
|
||||
@@ -200,7 +189,6 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text}
|
||||
@@ -210,7 +198,6 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes}
|
||||
@@ -220,25 +207,20 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
@@ -22,7 +22,6 @@ pip install nonebot2[httpx]
|
||||
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -38,11 +37,9 @@ pip install nonebot2[httpx]
|
||||
### _async method_ `request(setup)` {#Session-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _async method_ `setup()` {#Session-setup}
|
||||
@@ -52,7 +49,6 @@ pip install nonebot2[httpx]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close()` {#Session-close}
|
||||
@@ -62,7 +58,6 @@ pip install nonebot2[httpx]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -76,17 +71,14 @@ pip install nonebot2[httpx]
|
||||
### _async method_ `request(setup)` {#Mixin-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -100,13 +92,11 @@ pip install nonebot2[httpx]
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Session
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -40,11 +40,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 设置一个 HTTP 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server}
|
||||
@@ -52,23 +50,19 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 设置一个 WebSocket 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Cookies(cookies=None)` {#Cookies}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cookies` (CookieTypes)
|
||||
|
||||
### _method_ `set(name, value, domain="", path="/")` {#Cookies-set}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `value` (str)
|
||||
@@ -78,13 +72,11 @@ description: nonebot.drivers 模块
|
||||
- `path` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `default` (str | None)
|
||||
@@ -94,13 +86,11 @@ description: nonebot.drivers 模块
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | None
|
||||
|
||||
### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `domain` (str | None)
|
||||
@@ -108,39 +98,32 @@ description: nonebot.drivers 模块
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `clear(domain=None, path=None)` {#Cookies-clear}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `domain` (str | None)
|
||||
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `update(cookies=None)` {#Cookies-update}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cookies` (CookieTypes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `as_header(request)` {#Cookies-as-header}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (Request)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, str]
|
||||
|
||||
## _abstract class_ `Driver(env, config)` {#Driver}
|
||||
@@ -152,7 +135,6 @@ description: nonebot.drivers 模块
|
||||
驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象
|
||||
|
||||
- `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象
|
||||
@@ -180,13 +162,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个协议适配器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类
|
||||
|
||||
- `**kwargs`: 其他传递给适配器的参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract property_ `type` {#Driver-type}
|
||||
@@ -206,13 +186,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 启动驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `on_startup(func)` {#Driver-on-startup}
|
||||
@@ -220,11 +198,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个启动时执行的函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
### _method_ `on_shutdown(func)` {#Driver-on-shutdown}
|
||||
@@ -232,11 +208,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个停止时执行的函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect}
|
||||
@@ -246,15 +220,12 @@ description: nonebot.drivers 模块
|
||||
装饰一个函数使他在 bot 连接成功时执行。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前连接上的 Bot 对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_BotConnectionHook](../typing.md#T-BotConnectionHook)
|
||||
|
||||
### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect}
|
||||
@@ -264,15 +235,12 @@ description: nonebot.drivers 模块
|
||||
装饰一个函数使他在 bot 连接断开时执行。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前连接上的 Bot 对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)
|
||||
|
||||
## _var_ `ForwardDriver` {#ForwardDriver}
|
||||
@@ -306,11 +274,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一个 HTTP 请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](#Response)
|
||||
|
||||
### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session}
|
||||
@@ -318,7 +284,6 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 获取一个 HTTP 会话
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -332,7 +297,6 @@ description: nonebot.drivers 模块
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- HTTPClientSession
|
||||
|
||||
## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup}
|
||||
@@ -350,7 +314,6 @@ description: nonebot.drivers 模块
|
||||
- **参数**
|
||||
|
||||
auto
|
||||
|
||||
- `H10: '1.0'`
|
||||
|
||||
- `H11: '1.1'`
|
||||
@@ -374,7 +337,6 @@ description: nonebot.drivers 模块
|
||||
## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `method` (str | bytes)
|
||||
|
||||
- `url` (URL | str | RawURL)
|
||||
@@ -402,7 +364,6 @@ description: nonebot.drivers 模块
|
||||
## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `status_code` (int)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -432,7 +393,6 @@ description: nonebot.drivers 模块
|
||||
## _abstract class_ `WebSocket(*, request)` {#WebSocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (Request)
|
||||
|
||||
### _abstract property_ `closed` {#WebSocket-closed}
|
||||
@@ -450,7 +410,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
@@ -458,13 +417,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 关闭 WebSocket 连接请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -476,7 +433,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _abstract async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -488,7 +444,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -500,7 +455,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send(data)` {#WebSocket-send}
|
||||
@@ -508,11 +462,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket text/bytes 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str | bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
@@ -520,11 +472,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket text 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
@@ -532,11 +482,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket binary 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin}
|
||||
@@ -552,11 +500,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发起一个 WebSocket 连接
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](#WebSocket), None]
|
||||
|
||||
## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup}
|
||||
@@ -574,19 +520,14 @@ description: nonebot.drivers 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(driver) -> type[D]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` (type[D])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[D]
|
||||
|
||||
**2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` (type[D])
|
||||
|
||||
- `__m` (type[[Mixin](#Mixin)])
|
||||
@@ -594,5 +535,4 @@ description: nonebot.drivers 模块
|
||||
- `*mixins` (type[[Mixin](#Mixin)])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[CombinedDriver]
|
||||
|
@@ -18,7 +18,6 @@ None 驱动适配
|
||||
- **说明:** None 驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
@@ -40,13 +39,11 @@ None 驱动适配
|
||||
- **说明:** 启动 none driver
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `exit(force=False)` {#Driver-exit}
|
||||
@@ -54,9 +51,7 @@ None 驱动适配
|
||||
- **说明:** 退出 none driver
|
||||
|
||||
- **参数**
|
||||
|
||||
- `force` (bool): 强制退出
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
@@ -68,7 +68,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** Quart 驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` (NoneBotConfig)
|
||||
@@ -100,21 +99,17 @@ pip install nonebot2[quart]
|
||||
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
|
||||
@@ -122,7 +117,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** 使用 `uvicorn` 启动 Quart
|
||||
|
||||
- **参数**
|
||||
|
||||
- `host` (str | None)
|
||||
|
||||
- `port` (int | None)
|
||||
@@ -134,7 +128,6 @@ pip install nonebot2[quart]
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket}
|
||||
@@ -142,7 +135,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** Quart WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (BaseRequest)
|
||||
|
||||
- `websocket_ctx` (WebsocketContext)
|
||||
@@ -154,19 +146,16 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -176,7 +165,6 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -186,7 +174,6 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -196,25 +183,20 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
@@ -22,11 +22,9 @@ pip install nonebot2[websockets]
|
||||
## _def_ `catch_closed(func)` {#catch-closed}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ((P) -> CoroutineType[Any, Any, T])
|
||||
|
||||
- **返回**
|
||||
|
||||
- (P) -> CoroutineType[Any, Any, T]
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -40,11 +38,9 @@ pip install nonebot2[websockets]
|
||||
### _method_ `websocket(setup)` {#Mixin-websocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](index.md#WebSocket), None]
|
||||
|
||||
## _class_ `WebSocket(*, request, websocket)` {#WebSocket}
|
||||
@@ -52,7 +48,6 @@ pip install nonebot2[websockets]
|
||||
- **说明:** Websockets WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` ([Request](index.md#Request))
|
||||
|
||||
- `websocket` (WebSocketClientProtocol)
|
||||
@@ -64,19 +59,16 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -86,7 +78,6 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -96,7 +87,6 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -106,33 +96,27 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -62,7 +62,6 @@ NoneBotException
|
||||
- **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `reason`: 忽略事件的原因
|
||||
|
||||
## _class_ `SkippedException(<auto>)` {#SkippedException}
|
||||
@@ -101,7 +100,6 @@ NoneBotException
|
||||
- **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `result`: 返回的内容
|
||||
|
||||
## _class_ `StopPropagation(<auto>)` {#StopPropagation}
|
||||
@@ -200,7 +198,6 @@ NoneBotException
|
||||
- **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter_name`: 标识 adapter
|
||||
|
||||
## _class_ `NoLogException(<auto>)` {#NoLogException}
|
||||
|
@@ -60,11 +60,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -80,27 +78,20 @@ description: nonebot 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(name) -> Adapter`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 适配器名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象
|
||||
|
||||
**2.** `(name) -> A`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (type[A]): 适配器类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -121,11 +112,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -143,11 +132,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any: Server App 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -167,11 +154,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any: ASGI 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -192,15 +177,12 @@ description: nonebot 模块
|
||||
当不提供时,返回一个 [Bot](adapters/index.md#Bot)。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- KeyError: 对应 self_id 的 Bot 不存在
|
||||
|
||||
- ValueError: 没有传入 self_id 且没有 Bot 可用
|
||||
@@ -224,13 +206,11 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键
|
||||
|
||||
[Bot](adapters/index.md#Bot) 对象为值的字典
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -250,13 +230,11 @@ description: nonebot 模块
|
||||
也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置
|
||||
|
||||
- `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
@@ -270,13 +248,11 @@ description: nonebot 模块
|
||||
- **说明:** 启动 NoneBot,即运行全局 [Driver](drivers/index.md#Driver) 对象。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数
|
||||
|
||||
- `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
|
@@ -25,7 +25,6 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||||
NoneBot 日志记录器对象。
|
||||
|
||||
默认信息:
|
||||
|
||||
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
|
||||
- 等级: `INFO` ,根据 `config.log_level` 配置改变
|
||||
- 输出: 输出至 stdout
|
||||
@@ -47,11 +46,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||||
### _method_ `emit(record)` {#LoguruHandler-emit}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `record` (logging.LogRecord)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _def_ `default_filter(record)` {#default-filter}
|
||||
@@ -59,11 +56,9 @@ NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||||
- **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `record` (Record)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _var_ `default_format` {#default-format}
|
||||
|
@@ -76,7 +76,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 创建一个新的事件响应器,并存储至 `matchers <#matchers>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (str): 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意
|
||||
|
||||
- `rule` ([Rule](rule.md#Rule) | None): 匹配规则
|
||||
@@ -106,7 +105,6 @@ description: nonebot.matcher 模块
|
||||
- `default_permission_updater` ([T_PermissionUpdater](typing.md#T-PermissionUpdater) | [Dependent](dependencies/index.md#Dependent)[[Permission](permission.md#Permission)] | None): 默认会话权限更新函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[Matcher]: 新的事件响应器类
|
||||
|
||||
### _classmethod_ `destroy()` {#Matcher-destroy}
|
||||
@@ -118,7 +116,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _classmethod_ `check_perm(bot, event, stack=None, dependency_cache=None)` {#Matcher-check-perm}
|
||||
@@ -126,7 +123,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 检查是否满足触发权限
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): 上报事件
|
||||
@@ -136,7 +132,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否满足权限
|
||||
|
||||
### _classmethod_ `check_rule(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-check-rule}
|
||||
@@ -144,7 +139,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 检查是否满足匹配规则
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): 上报事件
|
||||
@@ -156,7 +150,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否满足匹配规则
|
||||
|
||||
### _classmethod_ `type_updater(func)` {#Matcher-type-updater}
|
||||
@@ -164,11 +157,9 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_TypeUpdater](typing.md#T-TypeUpdater)): 响应事件类型更新函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_TypeUpdater](typing.md#T-TypeUpdater)
|
||||
|
||||
### _classmethod_ `permission_updater(func)` {#Matcher-permission-updater}
|
||||
@@ -176,23 +167,19 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来更改当前事件响应器的默认会话权限更新函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_PermissionUpdater](typing.md#T-PermissionUpdater)): 会话权限更新函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_PermissionUpdater](typing.md#T-PermissionUpdater)
|
||||
|
||||
### _classmethod_ `append_handler(handler, parameterless=None)` {#Matcher-append-handler}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `handler` ([T_Handler](typing.md#T-Handler))
|
||||
|
||||
- `parameterless` (Iterable[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Dependent](dependencies/index.md#Dependent)[Any]
|
||||
|
||||
### _classmethod_ `handle(parameterless=None)` {#Matcher-handle}
|
||||
@@ -200,11 +187,9 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来向事件响应器直接添加一个处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
|
||||
|
||||
### _classmethod_ `receive(id="", parameterless=None)` {#Matcher-receive}
|
||||
@@ -212,13 +197,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str): 消息 ID
|
||||
|
||||
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
|
||||
|
||||
### _classmethod_ `got(key, prompt=None, parameterless=None)` {#Matcher-got}
|
||||
@@ -231,7 +214,6 @@ description: nonebot.matcher 模块
|
||||
如果 `key` 已存在则直接继续运行
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str): 参数名
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 在参数不存在时向用户发送的消息
|
||||
@@ -239,7 +221,6 @@ description: nonebot.matcher 模块
|
||||
- `parameterless` (Iterable[Any] | None): 非参数类型依赖列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- ([T_Handler](typing.md#T-Handler)) -> [T_Handler](typing.md#T-Handler)
|
||||
|
||||
### _classmethod_ `send(message, **kwargs)` {#Matcher-send}
|
||||
@@ -247,13 +228,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 发送一条消息给当前交互用户
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate)): 消息内容
|
||||
|
||||
- `**kwargs` (Any): [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _classmethod_ `finish(message=None, **kwargs)` {#Matcher-finish}
|
||||
@@ -261,13 +240,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 发送一条消息给当前交互用户并结束当前事件响应器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `pause(prompt=None, **kwargs)` {#Matcher-pause}
|
||||
@@ -275,13 +252,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `reject(prompt=None, **kwargs)` {#Matcher-reject}
|
||||
@@ -289,13 +264,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 最近使用 `got` / `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `reject_arg(key, prompt=None, **kwargs)` {#Matcher-reject-arg}
|
||||
@@ -303,7 +276,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 最近使用 `got` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一条消息后从头开始执行当前处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str): 参数名
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
@@ -311,7 +283,6 @@ description: nonebot.matcher 模块
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `reject_receive(id="", prompt=None, **kwargs)` {#Matcher-reject-receive}
|
||||
@@ -319,7 +290,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 最近使用 `receive` 接收的消息不符合预期, 发送一条消息给当前交互用户并将当前事件处理流程中断在当前位置,在接收用户新的一个事件后从头开始执行当前处理函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str): 消息 id
|
||||
|
||||
- `prompt` (str | [Message](adapters/index.md#Message) | [MessageSegment](adapters/index.md#MessageSegment) | [MessageTemplate](adapters/index.md#MessageTemplate) | None): 消息内容
|
||||
@@ -327,7 +297,6 @@ description: nonebot.matcher 模块
|
||||
- `**kwargs`: [Bot.send](adapters/index.md#Bot-send) 的参数, 请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _classmethod_ `skip()` {#Matcher-skip}
|
||||
@@ -343,7 +312,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- NoReturn
|
||||
|
||||
### _method_ `get_receive(id, default=None)` {#Matcher-get-receive}
|
||||
@@ -357,25 +325,19 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(id) -> Event | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | None
|
||||
|
||||
**2.** `(id, default) -> Event | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str)
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | T
|
||||
|
||||
### _method_ `set_receive(id, event)` {#Matcher-set-receive}
|
||||
@@ -383,13 +345,11 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 设置一个 `receive` 事件
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str)
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get_last_receive(default=None)` {#Matcher-get-last-receive}
|
||||
@@ -403,23 +363,18 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `() -> Event | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | None
|
||||
|
||||
**2.** `(default) -> Event | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Event](adapters/index.md#Event) | T
|
||||
|
||||
### _method_ `get_arg(key, default=None)` {#Matcher-get-arg}
|
||||
@@ -433,25 +388,19 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(key) -> Message | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](adapters/index.md#Message) | None
|
||||
|
||||
**2.** `(key, default) -> Message | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](adapters/index.md#Message) | T
|
||||
|
||||
### _method_ `set_arg(key, message)` {#Matcher-set-arg}
|
||||
@@ -459,25 +408,21 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 设置一个 `got` 消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `message` ([Message](adapters/index.md#Message))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `set_target(target, cache=True)` {#Matcher-set-target}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `target` (str)
|
||||
|
||||
- `cache` (bool)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get_target(default=None)` {#Matcher-get-target}
|
||||
@@ -485,23 +430,18 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `() -> str | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | None
|
||||
|
||||
**2.** `(default) -> str | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | T
|
||||
|
||||
### _method_ `stop_propagation()` {#Matcher-stop-propagation}
|
||||
@@ -513,13 +453,11 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `update_type(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-type}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -529,13 +467,11 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `update_permission(bot, event, stack=None, dependency_cache=None)` {#Matcher-update-permission}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -545,7 +481,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Permission](permission.md#Permission)
|
||||
|
||||
### _async method_ `resolve_reject()` {#Matcher-resolve-reject}
|
||||
@@ -555,25 +490,21 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `ensure_context(bot, event)` {#Matcher-ensure-context}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `simple_run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-simple-run}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -585,13 +516,11 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `run(bot, event, state, stack=None, dependency_cache=None)` {#Matcher-run}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot))
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event))
|
||||
@@ -603,7 +532,6 @@ description: nonebot.matcher 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `MatcherManager()` {#MatcherManager}
|
||||
@@ -625,7 +553,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- KeysView[int]
|
||||
|
||||
### _method_ `values()` {#MatcherManager-values}
|
||||
@@ -635,7 +562,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- ValuesView[list[type[[Matcher](#Matcher)]]]
|
||||
|
||||
### _method_ `items()` {#MatcherManager-items}
|
||||
@@ -645,7 +571,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- ItemsView[int, list[type[[Matcher](#Matcher)]]]
|
||||
|
||||
### _method_ `get(key, default=None)` {#MatcherManager-get}
|
||||
@@ -653,35 +578,27 @@ description: nonebot.matcher 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(key) -> list[type[Matcher]] | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]] | None
|
||||
|
||||
**2.** `(key, default) -> list[type[Matcher]] | T`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- `default` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]] | T
|
||||
|
||||
### _method_ `pop(key)` {#MatcherManager-pop}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]]
|
||||
|
||||
### _method_ `popitem()` {#MatcherManager-popitem}
|
||||
@@ -691,7 +608,6 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[int, list[type[[Matcher](#Matcher)]]]
|
||||
|
||||
### _method_ `clear()` {#MatcherManager-clear}
|
||||
@@ -701,29 +617,24 @@ description: nonebot.matcher 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `update(m, /)` {#MatcherManager-update}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `m` (MutableMapping[int, list[type[[Matcher](#Matcher)]]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `setdefault(key, default)` {#MatcherManager-setdefault}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (int)
|
||||
|
||||
- `default` (list[type[[Matcher](#Matcher)]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[type[[Matcher](#Matcher)]]
|
||||
|
||||
### _method_ `set_provider(provider_class)` {#MatcherManager-set-provider}
|
||||
@@ -731,11 +642,9 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 设置事件响应器存储器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `provider_class` (type[[MatcherProvider](#MatcherProvider)]): 事件响应器存储器类
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _abstract class_ `MatcherProvider(matchers)` {#MatcherProvider}
|
||||
@@ -743,7 +652,6 @@ description: nonebot.matcher 模块
|
||||
- **说明:** 事件响应器存储器基类
|
||||
|
||||
- **参数**
|
||||
|
||||
- `matchers` (Mapping[int, list[type[[Matcher](#Matcher)]]]): 当前存储器中已有的事件响应器
|
||||
|
||||
## _var_ `matchers` {#matchers}
|
||||
|
@@ -20,11 +20,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_EventPreProcessor](typing.md#T-EventPreProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_EventPreProcessor](typing.md#T-EventPreProcessor)
|
||||
|
||||
## _def_ `event_postprocessor(func)` {#event-postprocessor}
|
||||
@@ -36,11 +34,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_EventPostProcessor](typing.md#T-EventPostProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_EventPostProcessor](typing.md#T-EventPostProcessor)
|
||||
|
||||
## _def_ `run_preprocessor(func)` {#run-preprocessor}
|
||||
@@ -52,11 +48,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次事件响应器运行前执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_RunPreProcessor](typing.md#T-RunPreProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_RunPreProcessor](typing.md#T-RunPreProcessor)
|
||||
|
||||
## _def_ `run_postprocessor(func)` {#run-postprocessor}
|
||||
@@ -68,11 +62,9 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
装饰一个函数,使它在每次事件响应器运行后执行。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_RunPostProcessor](typing.md#T-RunPostProcessor))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_RunPostProcessor](typing.md#T-RunPostProcessor)
|
||||
|
||||
## _async def_ `check_and_run_matcher(Matcher, bot, event, state, stack=None, dependency_cache=None)` {#check-and-run-matcher}
|
||||
@@ -80,7 +72,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
- **说明:** 检查并运行事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `Matcher` (type[[Matcher](matcher.md#Matcher)]): 事件响应器
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
@@ -94,7 +85,6 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _async def_ `handle_event(bot, event)` {#handle-event}
|
||||
@@ -102,13 +92,11 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
|
||||
- **说明:** 处理一个事件。调用该函数以实现分发事件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
|
@@ -14,11 +14,9 @@ description: nonebot.params 模块
|
||||
- **说明:** Arg 参数消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _class_ `ArgParam(*args, key, type, **kwargs)` {#ArgParam}
|
||||
@@ -33,7 +31,6 @@ description: nonebot.params 模块
|
||||
留空则会根据参数名称获取。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `key` (str)
|
||||
@@ -47,11 +44,9 @@ description: nonebot.params 模块
|
||||
- **说明:** Arg 参数消息纯文本
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `ArgPromptResult(key=None)` {#ArgPromptResult}
|
||||
@@ -59,11 +54,9 @@ description: nonebot.params 模块
|
||||
- **说明:** `arg` prompt 发送结果
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `ArgStr(key=None)` {#ArgStr}
|
||||
@@ -71,11 +64,9 @@ description: nonebot.params 模块
|
||||
- **说明:** Arg 参数消息文本
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _class_ `BotParam(*args, checker=None, **kwargs)` {#BotParam}
|
||||
@@ -89,7 +80,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `bot` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `checker` ([ModelField](compat.md#ModelField) | None)
|
||||
@@ -107,7 +97,6 @@ description: nonebot.params 模块
|
||||
本注入参数应该具有最低优先级,因此应该在所有其他注入参数之后使用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -125,7 +114,6 @@ description: nonebot.params 模块
|
||||
本注入应该具有最高优先级,因此应该在其他参数之前检查。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `dependent` ([Dependent](dependencies/index.md#Dependent)[Any])
|
||||
@@ -139,7 +127,6 @@ description: nonebot.params 模块
|
||||
- **说明:** 子依赖装饰器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `dependency` ([T_Handler](typing.md#T-Handler) | None): 依赖函数。默认为参数的类型注释。
|
||||
|
||||
- `use_cache` (bool): 是否使用缓存。默认为 `True`。
|
||||
@@ -147,7 +134,6 @@ description: nonebot.params 模块
|
||||
- `validate` (bool | PydanticFieldInfo): 是否使用 Pydantic 类型校验。默认为 `False`。
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
- **用法**
|
||||
@@ -180,7 +166,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `event` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `checker` ([ModelField](compat.md#ModelField) | None)
|
||||
@@ -198,7 +183,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `exception` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -216,7 +200,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `matcher` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `checker` ([ModelField](compat.md#ModelField) | None)
|
||||
@@ -234,7 +217,6 @@ description: nonebot.params 模块
|
||||
为保证兼容性,本注入还会解析名为 `state` 且没有类型注解的参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -250,7 +232,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `EventMessage()` {#EventMessage}
|
||||
@@ -262,7 +243,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `EventPlainText()` {#EventPlainText}
|
||||
@@ -274,7 +254,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `EventToMe()` {#EventToMe}
|
||||
@@ -286,7 +265,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `Command()` {#Command}
|
||||
@@ -298,7 +276,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[str, ...]
|
||||
|
||||
## _def_ `RawCommand()` {#RawCommand}
|
||||
@@ -310,7 +287,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `CommandArg()` {#CommandArg}
|
||||
@@ -322,7 +298,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `CommandStart()` {#CommandStart}
|
||||
@@ -334,7 +309,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `CommandWhitespace()` {#CommandWhitespace}
|
||||
@@ -346,7 +320,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `ShellCommandArgs()` {#ShellCommandArgs}
|
||||
@@ -358,7 +331,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `ShellCommandArgv()` {#ShellCommandArgv}
|
||||
@@ -370,7 +342,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `RegexMatched()` {#RegexMatched}
|
||||
@@ -382,7 +353,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Match[str]
|
||||
|
||||
## _def_ `RegexStr(*groups)` {#RegexStr}
|
||||
@@ -392,29 +362,21 @@ description: nonebot.params 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(group, /) -> str`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `group` (Literal[0])
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
**2.** `(group, /) -> str | Any`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `group` (str | int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | Any
|
||||
|
||||
**3.** `(group1, group2, /, *groups) -> tuple[str | Any, ...]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `group1` (str | int)
|
||||
|
||||
- `group2` (str | int)
|
||||
@@ -422,7 +384,6 @@ description: nonebot.params 模块
|
||||
- `*groups` (str | int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[str | Any, ...]
|
||||
|
||||
## _def_ `RegexGroup()` {#RegexGroup}
|
||||
@@ -434,7 +395,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Any, ...]
|
||||
|
||||
## _def_ `RegexDict()` {#RegexDict}
|
||||
@@ -446,7 +406,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `Startswith()` {#Startswith}
|
||||
@@ -458,7 +417,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Endswith()` {#Endswith}
|
||||
@@ -470,7 +428,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Fullmatch()` {#Fullmatch}
|
||||
@@ -482,7 +439,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Keyword()` {#Keyword}
|
||||
@@ -494,7 +450,6 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `Received(id=None, default=None)` {#Received}
|
||||
@@ -502,13 +457,11 @@ description: nonebot.params 模块
|
||||
- **说明:** `receive` 事件参数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str | None)
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `LastReceived(default=None)` {#LastReceived}
|
||||
@@ -516,11 +469,9 @@ description: nonebot.params 模块
|
||||
- **说明:** `last_receive` 事件参数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `ReceivePromptResult(id=None)` {#ReceivePromptResult}
|
||||
@@ -528,11 +479,9 @@ description: nonebot.params 模块
|
||||
- **说明:** `receive` prompt 发送结果
|
||||
|
||||
- **参数**
|
||||
|
||||
- `id` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `PausePromptResult()` {#PausePromptResult}
|
||||
@@ -544,5 +493,4 @@ description: nonebot.params 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -22,7 +22,6 @@ description: nonebot.permission 模块
|
||||
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有检查函数的会话 ID 限制。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*users` (str)
|
||||
|
||||
- `perm` (Permission | None): 需要同时满足的权限
|
||||
@@ -30,7 +29,6 @@ description: nonebot.permission 模块
|
||||
- `user`: 会话白名单
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `Permission(*checkers)` {#Permission}
|
||||
@@ -42,7 +40,6 @@ description: nonebot.permission 模块
|
||||
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*checkers` ([T_PermissionChecker](typing.md#T-PermissionChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): PermissionChecker
|
||||
|
||||
- **用法**
|
||||
@@ -64,7 +61,6 @@ description: nonebot.permission 模块
|
||||
- **说明:** 检查是否满足某个权限。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
@@ -74,7 +70,6 @@ description: nonebot.permission 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `User(users, perm=None)` {#User}
|
||||
@@ -82,7 +77,6 @@ description: nonebot.permission 模块
|
||||
- **说明:** 检查当前事件是否属于指定会话。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `users` (tuple[str, ...]): 会话 ID 元组
|
||||
|
||||
- `perm` (Permission | None): 需同时满足的权限
|
||||
@@ -96,13 +90,11 @@ description: nonebot.permission 模块
|
||||
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
|
||||
- `perm` (Permission | None): 需同时满足的权限
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _classmethod_ `from_permission(*users, perm=None)` {#User-from-permission}
|
||||
@@ -114,13 +106,11 @@ description: nonebot.permission 模块
|
||||
如果 `perm` 中仅有 `User` 类型的权限检查函数,则会去除原有的会话 ID 限制。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*users` (str): 会话白名单
|
||||
|
||||
- `perm` (Permission | None): 需同时满足的权限
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
## _class_ `Message(<auto>)` {#Message}
|
||||
|
@@ -51,11 +51,9 @@ description: nonebot.plugin 模块
|
||||
如果为嵌套的子插件,标识符为 `父插件标识符:子插件文件(夹)名`。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `plugin_id` (str): 插件标识符,即 [Plugin.id\_](model.md#Plugin-id-)。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `get_plugin_by_module_name(module_name)` {#get-plugin-by-module-name}
|
||||
@@ -67,11 +65,9 @@ description: nonebot.plugin 模块
|
||||
如果提供的模块名为某个插件的子模块,同样会返回该插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_name` (str): 模块名,即 [Plugin.module_name](model.md#Plugin-module-name)。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `get_loaded_plugins()` {#get-loaded-plugins}
|
||||
@@ -83,7 +79,6 @@ description: nonebot.plugin 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `get_available_plugin_names()` {#get-available-plugin-names}
|
||||
@@ -95,7 +90,6 @@ description: nonebot.plugin 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[str]
|
||||
|
||||
## _def_ `get_plugin_config(config)` {#get-plugin-config}
|
||||
@@ -103,9 +97,7 @@ description: nonebot.plugin 模块
|
||||
- **说明:** 从全局配置获取当前插件需要的配置项。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `config` (type[C])
|
||||
|
||||
- **返回**
|
||||
|
||||
- C
|
||||
|
@@ -14,11 +14,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_path` (str | Path): 插件名称 `path.to.your.plugin` 或插件路径 `pathlib.Path(path/to/your/plugin)`
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `load_plugins(*plugin_dir)` {#load-plugins}
|
||||
@@ -26,11 +24,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入文件夹下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*plugin_dir` (str): 文件夹路径
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `load_all_plugins(module_path, plugin_dir)` {#load-all-plugins}
|
||||
@@ -38,13 +34,11 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_path` (Iterable[str]): 指定插件集合
|
||||
|
||||
- `plugin_dir` (Iterable[str]): 指定文件夹路径集合
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `load_from_json(file_path, encoding="utf-8")` {#load-from-json}
|
||||
@@ -52,13 +46,11 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `file_path` (str): 指定 json 文件路径
|
||||
|
||||
- `encoding` (str): 指定 json 文件编码
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
- **用法**
|
||||
@@ -79,13 +71,11 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件。 以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `file_path` (str): 指定 toml 文件路径
|
||||
|
||||
- `encoding` (str): 指定 toml 文件编码
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
- **用法**
|
||||
@@ -105,11 +95,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入 NoneBot 内置插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `load_builtin_plugins(*plugins)` {#load-builtin-plugins}
|
||||
@@ -117,11 +105,9 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 导入多个 NoneBot 内置插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*plugins` (str): 插件名称列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _def_ `require(name)` {#require}
|
||||
@@ -129,15 +115,12 @@ description: nonebot.plugin.load 模块
|
||||
- **说明:** 声明依赖插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件模块名或插件标识符,仅在已声明插件的情况下可使用标识符。
|
||||
|
||||
- **返回**
|
||||
|
||||
- ModuleType
|
||||
|
||||
- **异常**
|
||||
|
||||
- RuntimeError: 插件无法加载
|
||||
|
||||
## _def_ `inherit_supported_adapters(*names)` {#inherit-supported-adapters}
|
||||
@@ -149,15 +132,12 @@ description: nonebot.plugin.load 模块
|
||||
如果传入了多个插件名称,返回值会自动取交集。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*names` (str): 插件名称列表。
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[str] | None
|
||||
|
||||
- **异常**
|
||||
|
||||
- RuntimeError: 插件未加载
|
||||
|
||||
- ValueError: 插件缺少元数据
|
||||
|
@@ -16,7 +16,6 @@ description: nonebot.plugin.manager 模块
|
||||
- **说明:** 插件管理器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `plugins` (Iterable[str] | None): 独立插件模块名集合。
|
||||
|
||||
- `search_path` (Iterable[str] | None): 插件搜索路径(文件夹),相对于当前工作目录。
|
||||
@@ -54,11 +53,9 @@ description: nonebot.plugin.manager 模块
|
||||
可以使用完整插件模块名或者插件标识符加载。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名称或插件标识符。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
### _method_ `load_all_plugins()` {#PluginManager-load-all-plugins}
|
||||
@@ -70,7 +67,6 @@ description: nonebot.plugin.manager 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](model.md#Plugin)]
|
||||
|
||||
## _class_ `PluginFinder(<auto>)` {#PluginFinder}
|
||||
@@ -82,7 +78,6 @@ description: nonebot.plugin.manager 模块
|
||||
### _method_ `find_spec(fullname, path, target=None)` {#PluginFinder-find-spec}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `fullname` (str)
|
||||
|
||||
- `path` (Sequence[str] | None)
|
||||
@@ -90,13 +85,11 @@ description: nonebot.plugin.manager 模块
|
||||
- `target` (ModuleType | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `manager` (PluginManager)
|
||||
|
||||
- `fullname` (str)
|
||||
@@ -106,19 +99,15 @@ description: nonebot.plugin.manager 模块
|
||||
### _method_ `create_module(spec)` {#PluginLoader-create-module}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `spec`
|
||||
|
||||
- **返回**
|
||||
|
||||
- ModuleType | None
|
||||
|
||||
### _method_ `exec_module(module)` {#PluginLoader-exec-module}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module` (ModuleType)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
@@ -80,7 +80,6 @@ description: nonebot.plugin.model 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[type[[Adapter](../adapters/index.md#Adapter)]] | None
|
||||
|
||||
## _class_ `Plugin(<auto>)` {#Plugin}
|
||||
|
@@ -14,11 +14,9 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 存储一个事件响应器到插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `matcher` (type[[Matcher](../matcher.md#Matcher)]): 事件响应器
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _def_ `get_matcher_plugin(depth=...)` {#get-matcher-plugin}
|
||||
@@ -30,11 +28,9 @@ description: nonebot.plugin.on 模块
|
||||
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `depth` (int): 调用栈深度
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](model.md#Plugin) | None
|
||||
|
||||
## _def_ `get_matcher_module(depth=...)` {#get-matcher-module}
|
||||
@@ -46,11 +42,9 @@ description: nonebot.plugin.on 模块
|
||||
**Deprecated**, 请使用 [get_matcher_source](#get-matcher-source) 获取信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `depth` (int): 调用栈深度
|
||||
|
||||
- **返回**
|
||||
|
||||
- ModuleType | None
|
||||
|
||||
## _def_ `get_matcher_source(depth=...)` {#get-matcher-source}
|
||||
@@ -58,11 +52,9 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 获取事件响应器定义所在源码信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `depth` (int): 调用栈深度
|
||||
|
||||
- **返回**
|
||||
|
||||
- MatcherSource | None
|
||||
|
||||
## _def_ `on(type="", rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on}
|
||||
@@ -70,7 +62,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个基础事件响应器,可自定义类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str): 事件响应器类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -90,7 +81,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_metaevent(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-metaevent}
|
||||
@@ -98,7 +88,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个元事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -116,7 +105,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-message}
|
||||
@@ -124,7 +112,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -142,7 +129,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_notice(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-notice}
|
||||
@@ -150,7 +136,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个通知事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -168,7 +153,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_request(rule=..., permission=..., *, handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-request}
|
||||
@@ -176,7 +160,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个请求事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -194,7 +177,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-startswith}
|
||||
@@ -202,7 +184,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -224,7 +205,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-endswith}
|
||||
@@ -232,7 +212,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息结尾内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -254,7 +233,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_fullmatch(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-fullmatch}
|
||||
@@ -262,7 +240,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -284,7 +261,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-keyword}
|
||||
@@ -292,7 +268,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `keywords` (set[str]): 关键词列表
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -312,7 +287,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_command(cmd, rule=..., aliases=..., force_whitespace=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-command}
|
||||
@@ -324,7 +298,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -348,7 +321,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-shell-command}
|
||||
@@ -363,7 +335,6 @@ description: nonebot.plugin.on 模块
|
||||
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -387,7 +358,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-regex}
|
||||
@@ -399,7 +369,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `pattern` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则匹配标志
|
||||
@@ -421,7 +390,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _def_ `on_type(types, rule=..., *, permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#on-type}
|
||||
@@ -429,7 +397,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)], ...]): 事件类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -449,13 +416,11 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _class_ `CommandGroup(cmd, prefix_aliases=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...])
|
||||
|
||||
- `prefix_aliases` (bool)
|
||||
@@ -481,7 +446,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个新的命令。新参数将会覆盖命令组默认值
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -505,7 +469,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `shell_command(cmd, *, rule=..., aliases=..., parser=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#CommandGroup-shell-command}
|
||||
@@ -513,7 +476,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个新的 `shell_like` 命令。新参数将会覆盖命令组默认值
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -537,13 +499,11 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str)
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None)
|
||||
@@ -567,7 +527,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个基础事件响应器,可自定义类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str): 事件响应器类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -587,7 +546,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_metaevent(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-metaevent}
|
||||
@@ -595,7 +553,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个元事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -613,7 +570,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_message(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-message}
|
||||
@@ -621,7 +577,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -639,7 +594,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_notice(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-notice}
|
||||
@@ -647,7 +601,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个通知事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -665,7 +618,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_request(*, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-request}
|
||||
@@ -673,7 +625,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个请求事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
|
||||
- `permission` ([Permission](../permission.md#Permission) | [T_PermissionChecker](../typing.md#T-PermissionChecker) | None): 事件响应权限
|
||||
@@ -691,7 +642,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_startswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-startswith}
|
||||
@@ -699,7 +649,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -721,7 +670,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_endswith(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-endswith}
|
||||
@@ -729,7 +677,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息结尾内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -751,7 +698,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_fullmatch(msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-fullmatch}
|
||||
@@ -759,7 +705,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息的**文本部分**与指定内容完全一致时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息全匹配内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -781,7 +726,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_keyword(keywords, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-keyword}
|
||||
@@ -789,7 +733,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `keywords` (set[str]): 关键词列表
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -809,7 +752,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_command(cmd, aliases=..., force_whitespace=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-command}
|
||||
@@ -821,7 +763,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
@@ -845,7 +786,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_shell_command(cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-shell-command}
|
||||
@@ -860,7 +800,6 @@ description: nonebot.plugin.on 模块
|
||||
通过 [ShellCommandArgs](../params.md#ShellCommandArgs) 获取解析后的参数字典。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
@@ -884,7 +823,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_regex(pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-regex}
|
||||
@@ -896,7 +834,6 @@ description: nonebot.plugin.on 模块
|
||||
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `pattern` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则匹配标志
|
||||
@@ -918,7 +855,6 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
||||
### _method_ `on_type(types, *, rule=..., permission=..., handlers=..., temp=..., expire_time=..., priority=..., block=..., state=...)` {#MatcherGroup-on-type}
|
||||
@@ -926,7 +862,6 @@ description: nonebot.plugin.on 模块
|
||||
- **说明:** 注册一个事件响应器,并且当事件为指定类型时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `types` (type[[Event](../adapters/index.md#Event)] | tuple[type[[Event](../adapters/index.md#Event)]]): 事件类型
|
||||
|
||||
- `rule` ([Rule](../rule.md#Rule) | [T_RuleChecker](../typing.md#T-RuleChecker) | None): 事件响应规则
|
||||
@@ -946,5 +881,4 @@ description: nonebot.plugin.on 模块
|
||||
- `state` ([T_State](../typing.md#T-State) | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[[Matcher](../matcher.md#Matcher)]
|
||||
|
@@ -22,7 +22,6 @@ description: nonebot.rule 模块
|
||||
当事件传递时,在 [Matcher](matcher.md#Matcher) 运行前进行检查。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*checkers` ([T_RuleChecker](typing.md#T-RuleChecker) | [Dependent](dependencies/index.md#Dependent)[bool]): RuleChecker
|
||||
|
||||
- **用法**
|
||||
@@ -44,7 +43,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查是否符合所有规则
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](adapters/index.md#Bot)): Bot 对象
|
||||
|
||||
- `event` ([Event](adapters/index.md#Event)): Event 对象
|
||||
@@ -56,7 +54,6 @@ description: nonebot.rule 模块
|
||||
- `dependency_cache` ([T_DependencyCache](typing.md#T-DependencyCache) | None): 依赖缓存
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `CMD_RESULT(<auto>)` {#CMD-RESULT}
|
||||
@@ -78,7 +75,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否以指定字符串开头。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (tuple[str, ...]): 指定消息开头字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -88,13 +84,11 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配消息纯文本开头。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `EndswithRule(msg, ignorecase=False)` {#EndswithRule}
|
||||
@@ -102,7 +96,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否以指定字符串结尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (tuple[str, ...]): 指定消息结尾字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -112,13 +105,11 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配消息纯文本结尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `FullmatchRule(msg, ignorecase=False)` {#FullmatchRule}
|
||||
@@ -126,7 +117,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否与指定字符串全匹配。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (tuple[str, ...]): 指定消息全匹配字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
@@ -136,13 +126,11 @@ description: nonebot.rule 模块
|
||||
- **说明:** 完全匹配消息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息全匹配字符串元组
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `KeywordsRule(*keywords)` {#KeywordsRule}
|
||||
@@ -150,7 +138,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息纯文本是否包含指定关键字。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*keywords` (str): 指定关键字元组
|
||||
|
||||
## _def_ `keyword(*keywords)` {#keyword}
|
||||
@@ -158,11 +145,9 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配消息纯文本关键词。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*keywords` (str): 指定关键字元组
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `CommandRule(cmds, force_whitespace=None)` {#CommandRule}
|
||||
@@ -170,7 +155,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息是否为指定命令。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表
|
||||
|
||||
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
|
||||
@@ -189,13 +173,11 @@ description: nonebot.rule 模块
|
||||
通过 [CommandArg](params.md#CommandArg) 获取匹配成功的命令参数。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
|
||||
|
||||
- `force_whitespace` (str | bool | None): 是否强制命令后必须有指定空白符
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
- **用法**
|
||||
@@ -231,37 +213,28 @@ description: nonebot.rule 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(args=None, namespace=None) -> tuple[Namespace, list[str | MessageSegment]]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
|
||||
|
||||
- `namespace` (None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Namespace, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
|
||||
|
||||
**2.** `(args, namespace) -> tuple[T, list[str | MessageSegment]]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (Sequence[str | [MessageSegment](adapters/index.md#MessageSegment)] | None)
|
||||
|
||||
- `namespace` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
|
||||
|
||||
**3.** `(*, namespace) -> tuple[T, list[str | MessageSegment]]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `namespace` (T)
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[T, list[str | [MessageSegment](adapters/index.md#MessageSegment)]]
|
||||
|
||||
## _class_ `ShellCommandRule(cmds, parser)` {#ShellCommandRule}
|
||||
@@ -269,7 +242,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息是否为指定 shell 命令。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmds` (list[tuple[str, ...]]): 指定命令元组列表
|
||||
|
||||
- `parser` (ArgumentParser | None): 可选参数解析器
|
||||
@@ -298,13 +270,11 @@ description: nonebot.rule 模块
|
||||
:::
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*cmds` (str | tuple[str, ...]): 命令文本或命令元组
|
||||
|
||||
- `parser` (ArgumentParser | None): [ArgumentParser](#ArgumentParser) 对象
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
- **用法**
|
||||
@@ -330,7 +300,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查消息字符串是否符合指定正则表达式。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `regex` (str): 正则表达式
|
||||
|
||||
- `flags` (int): 正则表达式标记
|
||||
@@ -346,13 +315,11 @@ description: nonebot.rule 模块
|
||||
通过 [RegexDict](params.md#RegexDict) 获取匹配成功的 group 字典。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `regex` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则表达式标记
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
:::tip 提示
|
||||
@@ -380,7 +347,6 @@ description: nonebot.rule 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
||||
## _class_ `IsTypeRule(*types)` {#IsTypeRule}
|
||||
@@ -388,7 +354,6 @@ description: nonebot.rule 模块
|
||||
- **说明:** 检查事件类型是否为指定类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (type[[Event](adapters/index.md#Event)])
|
||||
|
||||
## _def_ `is_type(*types)` {#is-type}
|
||||
@@ -396,9 +361,7 @@ description: nonebot.rule 模块
|
||||
- **说明:** 匹配事件类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (type[[Event](adapters/index.md#Event)]): 事件类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Rule](#Rule)
|
||||
|
@@ -19,31 +19,25 @@ description: nonebot.typing 模块
|
||||
- **说明:** 标记一个方法为父类 interface 的 implement
|
||||
|
||||
- **参数**
|
||||
|
||||
- `InterfaceClass` (object)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _def_ `type_has_args(type_)` {#type-has-args}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `origin_is_union(origin)` {#origin-is-union}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `origin` (type[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `origin_is_literal(origin)` {#origin-is-literal}
|
||||
@@ -51,11 +45,9 @@ description: nonebot.typing 模块
|
||||
- **说明:** 判断是否是 Literal 类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `origin` (type[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `all_literal_values(type_)` {#all-literal-values}
|
||||
@@ -63,11 +55,9 @@ description: nonebot.typing 模块
|
||||
- **说明:** 获取 Literal 类型包含的所有值
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[Any]
|
||||
|
||||
## _def_ `origin_is_annotated(origin)` {#origin-is-annotated}
|
||||
@@ -75,11 +65,9 @@ description: nonebot.typing 模块
|
||||
- **说明:** 判断是否是 Annotated 类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `origin` (type[Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_none_type(type_)` {#is-none-type}
|
||||
@@ -87,17 +75,14 @@ description: nonebot.typing 模块
|
||||
- **说明:** 判断是否是 None 类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `evaluate_forwardref(ref, globalns, localns)` {#evaluate-forwardref}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `ref` (ForwardRef)
|
||||
|
||||
- `globalns` (dict[str, Any])
|
||||
@@ -105,7 +90,6 @@ description: nonebot.typing 模块
|
||||
- `localns` (dict[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _class_ `StateFlag(<auto>)` {#StateFlag}
|
||||
@@ -129,7 +113,6 @@ description: nonebot.typing 模块
|
||||
Bot 连接建立时钩子函数
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- DefaultParam: 带有默认值的参数
|
||||
@@ -143,7 +126,6 @@ description: nonebot.typing 模块
|
||||
Bot 连接断开时钩子函数
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- DefaultParam: 带有默认值的参数
|
||||
@@ -169,7 +151,6 @@ description: nonebot.typing 模块
|
||||
事件预处理函数 EventPreProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -185,7 +166,6 @@ description: nonebot.typing 模块
|
||||
事件后处理函数 EventPostProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -201,7 +181,6 @@ description: nonebot.typing 模块
|
||||
事件响应器运行前预处理函数 RunPreProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -218,7 +197,6 @@ description: nonebot.typing 模块
|
||||
事件响应器运行后后处理函数 RunPostProcessor 类型
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -236,7 +214,6 @@ description: nonebot.typing 模块
|
||||
RuleChecker 即判断是否响应事件的处理函数。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -252,7 +229,6 @@ description: nonebot.typing 模块
|
||||
PermissionChecker 即判断事件是否满足权限的处理函数。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -273,7 +249,6 @@ description: nonebot.typing 模块
|
||||
TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。 默认会更新为 `message`。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
@@ -290,7 +265,6 @@ description: nonebot.typing 模块
|
||||
PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。 默认会更新为当前事件的触发对象。
|
||||
|
||||
依赖参数:
|
||||
|
||||
- DependParam: 子依赖参数
|
||||
- BotParam: Bot 对象
|
||||
- EventParam: Event 对象
|
||||
|
@@ -18,11 +18,9 @@ description: nonebot.utils 模块
|
||||
参考: [loguru color 标签](https://loguru.readthedocs.io/en/stable/api/logger.html#color)
|
||||
|
||||
- **参数**
|
||||
|
||||
- `s` (str): 需要转义的字符串
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `deep_update(mapping, *updating_mappings)` {#deep-update}
|
||||
@@ -30,13 +28,11 @@ description: nonebot.utils 模块
|
||||
- **说明:** 深度更新合并字典
|
||||
|
||||
- **参数**
|
||||
|
||||
- `mapping` (dict[K, Any])
|
||||
|
||||
- `*updating_mappings` (dict[K, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[K, Any]
|
||||
|
||||
## _def_ `lenient_issubclass(cls, class_or_tuple)` {#lenient-issubclass}
|
||||
@@ -44,13 +40,11 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 cls 是否是 class_or_tuple 中的一个类型子类并忽略类型错误。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cls` (Any)
|
||||
|
||||
- `class_or_tuple` (type[Any] | tuple[type[Any], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `generic_check_issubclass(cls, class_or_tuple)` {#generic-check-issubclass}
|
||||
@@ -60,7 +54,6 @@ description: nonebot.utils 模块
|
||||
检查 cls 是否是 class_or_tuple 中的一个类型子类。
|
||||
|
||||
特别的:
|
||||
|
||||
- 如果 cls 是 `typing.Union` 或 `types.UnionType` 类型,
|
||||
则会检查其中的所有类型是否是 class_or_tuple 中一个类型的子类或 None。
|
||||
- 如果 cls 是 `typing.Literal` 类型,
|
||||
@@ -70,13 +63,11 @@ description: nonebot.utils 模块
|
||||
是否是 class_or_tuple 中一个类型的子类或 None。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cls` (Any)
|
||||
|
||||
- `class_or_tuple` (type[Any] | tuple[type[Any], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `type_is_complex(type_)` {#type-is-complex}
|
||||
@@ -84,11 +75,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 type\_ 是否是复杂类型
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_coroutine_callable(call)` {#is-coroutine-callable}
|
||||
@@ -96,11 +85,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 call 是否是一个 callable 协程函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_gen_callable(call)` {#is-gen-callable}
|
||||
@@ -108,11 +95,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 call 是否是一个生成器函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `is_async_gen_callable(call)` {#is-async-gen-callable}
|
||||
@@ -120,11 +105,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 检查 call 是否是一个异步生成器函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _def_ `run_sync(call)` {#run-sync}
|
||||
@@ -132,11 +115,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 一个用于包装 sync function 为 async function 的装饰器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((P) -> R): 被装饰的同步函数
|
||||
|
||||
- **返回**
|
||||
|
||||
- (P) -> Coroutine[None, None, R]
|
||||
|
||||
## _def_ `run_sync_ctx_manager(cm)` {#run-sync-ctx-manager}
|
||||
@@ -144,11 +125,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 一个用于包装 sync context manager 为 async context manager 的执行函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cm` (AbstractContextManager[T])
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[T, None]
|
||||
|
||||
## _async def_ `run_coro_with_catch(coro, exc, return_on_err=None)` {#run-coro-with-catch}
|
||||
@@ -158,9 +137,7 @@ description: nonebot.utils 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(coro, exc, return_on_err=None) -> T | None`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro` (Coroutine[Any, Any, T])
|
||||
|
||||
- `exc` (tuple[type[Exception], ...])
|
||||
@@ -168,13 +145,10 @@ description: nonebot.utils 模块
|
||||
- `return_on_err` (None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T | None
|
||||
|
||||
**2.** `(coro, exc, return_on_err) -> T | R`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro` (Coroutine[Any, Any, T])
|
||||
|
||||
- `exc` (tuple[type[Exception], ...])
|
||||
@@ -182,11 +156,9 @@ description: nonebot.utils 模块
|
||||
- `return_on_err` (R)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T | R
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro`: 要运行的协程
|
||||
|
||||
- `exc`: 要捕获的异常
|
||||
@@ -202,21 +174,17 @@ description: nonebot.utils 模块
|
||||
- **说明:** 运行协程并在取消时屏蔽取消异常。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `coro` (Coroutine[Any, Any, T]): 要运行的协程
|
||||
|
||||
- **返回**
|
||||
|
||||
- T: 协程的返回值
|
||||
|
||||
## _def_ `flatten_exception_group(exc_group)` {#flatten-exception-group}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `exc_group` (BaseExceptionGroup[E])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Generator[E, None, None]
|
||||
|
||||
## _def_ `get_name(obj)` {#get-name}
|
||||
@@ -224,11 +192,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 获取对象的名称
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `path_to_module_name(path)` {#path-to-module-name}
|
||||
@@ -236,11 +202,9 @@ description: nonebot.utils 模块
|
||||
- **说明:** 转换路径为模块名
|
||||
|
||||
- **参数**
|
||||
|
||||
- `path` (Path)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _def_ `resolve_dot_notation(obj_str, default_attr, default_prefix=None)` {#resolve-dot-notation}
|
||||
@@ -248,7 +212,6 @@ description: nonebot.utils 模块
|
||||
- **说明:** 解析并导入点分表示法的对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj_str` (str)
|
||||
|
||||
- `default_attr` (str)
|
||||
@@ -256,7 +219,6 @@ description: nonebot.utils 模块
|
||||
- `default_prefix` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _class_ `classproperty(func)` {#classproperty}
|
||||
@@ -264,7 +226,6 @@ description: nonebot.utils 模块
|
||||
- **说明:** 类属性装饰器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ((Any) -> T)
|
||||
|
||||
## _class_ `DataclassEncoder(<auto>)` {#DataclassEncoder}
|
||||
@@ -278,11 +239,9 @@ description: nonebot.utils 模块
|
||||
### _method_ `default(o)` {#DataclassEncoder-default}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `o`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _def_ `logger_wrapper(logger_name)` {#logger-wrapper}
|
||||
@@ -290,15 +249,12 @@ description: nonebot.utils 模块
|
||||
- **说明:** 用于打印 adapter 的日志。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `logger_name` (str): adapter 的名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped: 日志记录函数
|
||||
|
||||
日志记录函数的参数:
|
||||
|
||||
- level: 日志等级
|
||||
- message: 日志信息
|
||||
- exception: 异常信息
|
||||
|
@@ -278,7 +278,6 @@ opt2 = Option("--foo", default=OptionResult(value=False, args={"bar": 1}))
|
||||
`Arparma` 有如下属性:
|
||||
|
||||
- 调试类
|
||||
|
||||
- matched: 是否匹配成功
|
||||
- error_data: 解析失败时剩余的数据
|
||||
- error_info: 解析失败时的异常内容
|
||||
|
@@ -40,7 +40,7 @@ async def handle_function():
|
||||
|
||||
### 处理近似事件
|
||||
|
||||
对于一系列**差异不大**的事件,我们往往具有相同的处理逻辑。这时,我们不希望将相同的逻辑编写两遍,而应该复用代码,以实现在同一个事件处理函数中处理多个近似事件。我们可以使用[事件重载](../advanced/dependency.mdx#Event)的特性来实现这一功能。例如:
|
||||
对于一系列**差异不大**的事件,我们往往具有相同的处理逻辑。这时,我们不希望将相同的逻辑编写两遍,而应该复用代码,以实现在同一个事件处理函数中处理多个近似事件。我们可以使用[事件重载](../advanced/dependency.mdx#event)的特性来实现这一功能。例如:
|
||||
|
||||
<Tabs groupId="python">
|
||||
<TabItem value="3.10" label="Python 3.10+" default>
|
||||
|
@@ -155,7 +155,6 @@ async def test_example(app: App):
|
||||
1. `should_call_send`
|
||||
|
||||
定义事件响应器预期发送的消息,即通过[事件响应器操作 send](../../appendices/session-control.mdx#send)进行的操作。`should_call_send` 有四个参数:
|
||||
|
||||
- `event`:回复的目标事件。
|
||||
- `message`:预期的消息对象,可以是 `str`、`Message` 或 `MessageSegment`。
|
||||
- `result`:send 的返回值,将会返回给插件。
|
||||
@@ -163,8 +162,7 @@ async def test_example(app: App):
|
||||
- `**kwargs`:send 方法的额外参数。
|
||||
|
||||
2. `should_call_api`
|
||||
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-API)进行的操作。`should_call_api` 有四个参数:
|
||||
|
||||
定义事件响应器预期调用的平台 API 接口,即通过[调用平台 API](../../appendices/api-calling.mdx#调用平台-api)进行的操作。`should_call_api` 有四个参数:
|
||||
- `api`:API 名称。
|
||||
- `data`:预期的请求数据。
|
||||
- `result`:call_api 的返回值,将会返回给插件。
|
||||
|
@@ -20,7 +20,6 @@ description: nonebot.adapters 模块
|
||||
通常,在 Adapter 中编写协议通信相关代码,如: 建立通信连接、处理接收与发送 data 等。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` ([Driver](../drivers/index.md#Driver)): [Driver](../drivers/index.md#Driver) 实例
|
||||
|
||||
- `**kwargs` (Any): 其他由 [Driver.register_adapter](../drivers/index.md#Driver-register-adapter) 传入的额外参数
|
||||
@@ -46,7 +45,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _property_ `config` {#Adapter-config}
|
||||
@@ -64,11 +62,9 @@ description: nonebot.adapters 模块
|
||||
当有新的 [Bot](#Bot) 实例连接建立成功时调用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `bot_disconnect(bot)` {#Adapter-bot-disconnect}
|
||||
@@ -80,11 +76,9 @@ description: nonebot.adapters 模块
|
||||
当有 [Bot](#Bot) 实例连接断开时调用。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `bot` ([Bot](#Bot)): [Bot](#Bot) 实例
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `setup_http_server(setup)` {#Adapter-setup-http-server}
|
||||
@@ -92,11 +86,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 设置一个 HTTP 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](../drivers/index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Adapter-setup-websocket-server}
|
||||
@@ -104,11 +96,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 设置一个 WebSocket 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](../drivers/index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `request(setup)` {#Adapter-request}
|
||||
@@ -116,11 +106,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 进行一个 HTTP 客户端请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](../drivers/index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](../drivers/index.md#Response)
|
||||
|
||||
### _method_ `websocket(setup)` {#Adapter-websocket}
|
||||
@@ -128,21 +116,17 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 建立一个 WebSocket 客户端连接请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](../drivers/index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](../drivers/index.md#WebSocket), None]
|
||||
|
||||
### _method_ `on_ready(func)` {#Adapter-on-ready}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
## _abstract class_ `Bot(adapter, self_id)` {#Bot}
|
||||
@@ -154,7 +138,6 @@ description: nonebot.adapters 模块
|
||||
用于处理上报消息,并提供 API 调用接口。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter` ([Adapter](#Adapter)): 协议适配器实例
|
||||
|
||||
- `self_id` (str): 机器人 ID
|
||||
@@ -188,13 +171,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
|
||||
|
||||
- **参数**
|
||||
|
||||
- `api` (str): API 名称
|
||||
|
||||
- `**data` (Any): API 数据
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
- **用法**
|
||||
@@ -209,7 +190,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 调用机器人基础发送消息接口
|
||||
|
||||
- **参数**
|
||||
|
||||
- `event` ([Event](#Event)): 上报事件
|
||||
|
||||
- `message` (str | [Message](#Message) | [MessageSegment](#MessageSegment)): 要发送的消息
|
||||
@@ -217,7 +197,6 @@ description: nonebot.adapters 模块
|
||||
- `**kwargs` (Any): 任意额外参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _classmethod_ `on_calling_api(func)` {#Bot-on-calling-api}
|
||||
@@ -227,17 +206,14 @@ description: nonebot.adapters 模块
|
||||
调用 api 预处理。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前 bot 对象
|
||||
- api: 调用的 api 名称
|
||||
- data: api 调用的参数字典
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_CallingAPIHook](../typing.md#T-CallingAPIHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_CallingAPIHook](../typing.md#T-CallingAPIHook)
|
||||
|
||||
### _classmethod_ `on_called_api(func)` {#Bot-on-called-api}
|
||||
@@ -247,7 +223,6 @@ description: nonebot.adapters 模块
|
||||
调用 api 后处理。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前 bot 对象
|
||||
- exception: 调用 api 时发生的错误
|
||||
- api: 调用的 api 名称
|
||||
@@ -255,11 +230,9 @@ description: nonebot.adapters 模块
|
||||
- result: api 调用的返回
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_CalledAPIHook](../typing.md#T-CalledAPIHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_CalledAPIHook](../typing.md#T-CalledAPIHook)
|
||||
|
||||
## _abstract class_ `Event(<auto>)` {#Event}
|
||||
@@ -279,7 +252,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_event_name()` {#Event-get-event-name}
|
||||
@@ -291,7 +263,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_event_description()` {#Event-get-event-description}
|
||||
@@ -303,7 +274,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _method_ `get_log_string()` {#Event-get-log-string}
|
||||
@@ -320,11 +290,9 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
- **异常**
|
||||
|
||||
- NoLogException: 希望 NoneBot 隐藏该事件日志
|
||||
|
||||
### _abstract method_ `get_user_id()` {#Event-get-user-id}
|
||||
@@ -336,7 +304,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_session_id()` {#Event-get-session-id}
|
||||
@@ -348,7 +315,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `get_message()` {#Event-get-message}
|
||||
@@ -360,7 +326,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Message](#Message)
|
||||
|
||||
### _method_ `get_plaintext()` {#Event-get-plaintext}
|
||||
@@ -376,7 +341,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract method_ `is_tome()` {#Event-is-tome}
|
||||
@@ -388,7 +352,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _abstract class_ `Message(<auto>)` {#Message}
|
||||
@@ -396,7 +359,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 消息序列
|
||||
|
||||
- **参数**
|
||||
|
||||
- `message`: 消息内容
|
||||
|
||||
### _classmethod_ `template(format_string)` {#Message-template}
|
||||
@@ -410,11 +372,9 @@ description: nonebot.adapters 模块
|
||||
可以通过该消息类型的 `MessageSegment` 工厂方法创建消息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `format_string` (str | TM): 格式化模板
|
||||
|
||||
- **返回**
|
||||
|
||||
- [MessageTemplate](#MessageTemplate)[Self]: 消息格式化器
|
||||
|
||||
### _abstract classmethod_ `get_segment_class()` {#Message-get-segment-class}
|
||||
@@ -426,7 +386,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[TMS]
|
||||
|
||||
### _abstract staticmethod_ `_construct(msg)` {#Message--construct}
|
||||
@@ -434,11 +393,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 构造消息数组
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Iterable[TMS]
|
||||
|
||||
### _method_ `__getitem__(args)` {#Message---getitem--}
|
||||
@@ -446,53 +403,38 @@ description: nonebot.adapters 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (str): 消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 所有类型为 `args` 的消息段
|
||||
|
||||
**2.** `(args) -> TMS`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (tuple[str, int]): 消息段类型和索引
|
||||
|
||||
- **返回**
|
||||
|
||||
- TMS: 类型为 `args[0]` 的消息段第 `args[1]` 个
|
||||
|
||||
**3.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (tuple[str, slice]): 消息段类型和切片
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 类型为 `args[0]` 的消息段切片 `args[1]`
|
||||
|
||||
**4.** `(args) -> TMS`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (int): 索引
|
||||
|
||||
- **返回**
|
||||
|
||||
- TMS: 第 `args` 个消息段
|
||||
|
||||
**5.** `(args) -> Self`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `args` (slice): 切片
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 消息切片 `args`
|
||||
|
||||
### _method_ `__contains__(value)` {#Message---contains--}
|
||||
@@ -500,11 +442,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 检查消息段是否存在
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 消息内是否存在给定消息段或给定类型的消息段
|
||||
|
||||
### _method_ `has(value)` {#Message-has}
|
||||
@@ -512,11 +452,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 与 [`__contains__`](#Message---contains--) 相同
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
### _method_ `index(value, *args)` {#Message-index}
|
||||
@@ -524,7 +462,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 索引消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或者消息段类型
|
||||
|
||||
- `*args` (SupportsIndex)
|
||||
@@ -532,11 +469,9 @@ description: nonebot.adapters 模块
|
||||
- `arg`: start 与 end
|
||||
|
||||
- **返回**
|
||||
|
||||
- int: 索引 index
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 消息段不存在
|
||||
|
||||
### _method_ `get(type_, count=None)` {#Message-get}
|
||||
@@ -544,13 +479,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 获取指定类型的消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (str): 消息段类型
|
||||
|
||||
- `count` (int | None): 获取个数
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 构建的新消息
|
||||
|
||||
### _method_ `count(value)` {#Message-count}
|
||||
@@ -558,11 +491,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 计算指定消息段的个数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- int: 个数
|
||||
|
||||
### _method_ `only(value)` {#Message-only}
|
||||
@@ -570,11 +501,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 检查消息中是否仅包含指定消息段
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (TMS | str): 指定消息段或消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool: 是否仅包含指定消息段
|
||||
|
||||
### _method_ `append(obj)` {#Message-append}
|
||||
@@ -582,11 +511,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 添加一个消息段到消息数组末尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (str | TMS): 要添加的消息段
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `extend(obj)` {#Message-extend}
|
||||
@@ -594,11 +521,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 拼接一个消息数组或多个消息段到消息数组末尾。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `obj` (Self | Iterable[TMS]): 要添加的消息数组
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `join(iterable)` {#Message-join}
|
||||
@@ -606,11 +531,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 将多个消息连接并将自身作为分割
|
||||
|
||||
- **参数**
|
||||
|
||||
- `iterable` (Iterable[TMS | Self]): 要连接的消息
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 连接后的消息
|
||||
|
||||
### _method_ `copy()` {#Message-copy}
|
||||
@@ -622,7 +545,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `include(*types)` {#Message-include}
|
||||
@@ -630,11 +552,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 过滤消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (str): 包含的消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 新构造的消息
|
||||
|
||||
### _method_ `exclude(*types)` {#Message-exclude}
|
||||
@@ -642,11 +562,9 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 过滤消息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*types` (str): 不包含的消息段类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self: 新构造的消息
|
||||
|
||||
### _method_ `extract_plain_text()` {#Message-extract-plain-text}
|
||||
@@ -658,7 +576,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
## _abstract class_ `MessageSegment(<auto>)` {#MessageSegment}
|
||||
@@ -690,7 +607,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[TM]
|
||||
|
||||
### _abstract method_ `__str__()` {#MessageSegment---str--}
|
||||
@@ -702,29 +618,24 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _method_ `__add__(other)` {#MessageSegment---add--}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `other` (str | Self | Iterable[Self])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TM
|
||||
|
||||
### _method_ `get(key, default=None)` {#MessageSegment-get}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `key` (str)
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `keys()` {#MessageSegment-keys}
|
||||
@@ -734,7 +645,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `values()` {#MessageSegment-values}
|
||||
@@ -744,7 +654,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `items()` {#MessageSegment-items}
|
||||
@@ -754,17 +663,14 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `join(iterable)` {#MessageSegment-join}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `iterable` (Iterable[Self | TM])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TM
|
||||
|
||||
### _method_ `copy()` {#MessageSegment-copy}
|
||||
@@ -774,7 +680,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _abstract method_ `is_text()` {#MessageSegment-is-text}
|
||||
@@ -786,7 +691,6 @@ description: nonebot.adapters 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bool
|
||||
|
||||
## _class_ `MessageTemplate(template, factory=str, private_getattr=False)` {#MessageTemplate}
|
||||
@@ -794,7 +698,6 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 消息模板格式化实现类。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `template` (str | TM): 模板
|
||||
|
||||
- `factory` (type[str] | type[TM]): 消息类型工厂,默认为 `str`
|
||||
@@ -804,13 +707,11 @@ description: nonebot.adapters 模块
|
||||
### _method_ `add_format_spec(spec, name=None)` {#MessageTemplate-add-format-spec}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `spec` (FormatSpecFunc_T)
|
||||
|
||||
- `name` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- FormatSpecFunc_T
|
||||
|
||||
### _method_ `format(*args, **kwargs)` {#MessageTemplate-format}
|
||||
@@ -818,13 +719,11 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 根据传入参数和模板生成消息对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `format_map(mapping)` {#MessageTemplate-format-map}
|
||||
@@ -832,17 +731,14 @@ description: nonebot.adapters 模块
|
||||
- **说明:** 根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用
|
||||
|
||||
- **参数**
|
||||
|
||||
- `mapping` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `vformat(format_string, args, kwargs)` {#MessageTemplate-vformat}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `format_string` (str)
|
||||
|
||||
- `args` (Sequence[Any])
|
||||
@@ -850,13 +746,11 @@ description: nonebot.adapters 模块
|
||||
- `kwargs` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- TF
|
||||
|
||||
### _method_ `get_field(field_name, args, kwargs)` {#MessageTemplate-get-field}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field_name` (str)
|
||||
|
||||
- `args` (Sequence[Any])
|
||||
@@ -864,17 +758,14 @@ description: nonebot.adapters 模块
|
||||
- `kwargs` (Mapping[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Any, int | str]
|
||||
|
||||
### _method_ `format_field(value, format_spec)` {#MessageTemplate-format-field}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- `format_spec` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -36,7 +36,6 @@ description: nonebot.compat 模块
|
||||
- **说明:** FieldInfo class with extra property for compatibility with pydantic v1
|
||||
|
||||
- **参数**
|
||||
|
||||
- `default` (Any)
|
||||
|
||||
- `**kwargs` (Any)
|
||||
@@ -82,7 +81,6 @@ description: nonebot.compat 模块
|
||||
- **说明:** Construct a ModelField from given infos.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `annotation` (Any)
|
||||
@@ -90,7 +88,6 @@ description: nonebot.compat 模块
|
||||
- `field_info` (FieldInfo | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Self
|
||||
|
||||
### _method_ `get_default()` {#ModelField-get-default}
|
||||
@@ -102,7 +99,6 @@ description: nonebot.compat 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
### _method_ `validate_value(value)` {#ModelField-validate-value}
|
||||
@@ -110,11 +106,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate the value pass to the field.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `extract_field_info(field_info)` {#extract-field-info}
|
||||
@@ -122,11 +116,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get FieldInfo init kwargs from a FieldInfo instance.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field_info` (BaseFieldInfo)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `model_fields(model)` {#model-fields}
|
||||
@@ -134,11 +126,9 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get field list of a model.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (type[BaseModel])
|
||||
|
||||
- **返回**
|
||||
|
||||
- list[ModelField]
|
||||
|
||||
## _def_ `model_config(model)` {#model-config}
|
||||
@@ -146,17 +136,14 @@ description: nonebot.compat 模块
|
||||
- **说明:** Get config of a model.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (type[BaseModel])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `model_dump(model, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)` {#model-dump}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `model` (BaseModel)
|
||||
|
||||
- `include` (set[str] | None)
|
||||
@@ -172,7 +159,6 @@ description: nonebot.compat 模块
|
||||
- `exclude_none` (bool)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
||||
## _def_ `type_validate_python(type_, data)` {#type-validate-python}
|
||||
@@ -180,13 +166,11 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate data with given type.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[T])
|
||||
|
||||
- `data` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T
|
||||
|
||||
## _def_ `type_validate_json(type_, data)` {#type-validate-json}
|
||||
@@ -194,13 +178,11 @@ description: nonebot.compat 模块
|
||||
- **说明:** Validate JSON with given type.
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type_` (type[T])
|
||||
|
||||
- `data` (str | bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- T
|
||||
|
||||
## _def_ `custom_validation(class_)` {#custom-validation}
|
||||
@@ -208,9 +190,7 @@ description: nonebot.compat 模块
|
||||
- **说明:** Use pydantic v1 like validator generator in pydantic v2
|
||||
|
||||
- **参数**
|
||||
|
||||
- `class_` (type[CVC])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[CVC]
|
||||
|
@@ -24,7 +24,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
|
||||
将会从 **环境变量** > **dotenv 配置文件** 的优先级读取环境信息。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None)
|
||||
|
||||
- `_env_file_encoding` (str | None)
|
||||
@@ -55,7 +54,6 @@ NoneBot 使用 [`pydantic`](https://pydantic-docs.helpmanual.io/) 以及
|
||||
配置方法参考: [配置](https://nonebot.dev/docs/appendices/config)
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None)
|
||||
|
||||
- `_env_file_encoding` (str | None)
|
||||
|
@@ -18,7 +18,6 @@ description: nonebot.dependencies 模块
|
||||
继承自 `pydantic.fields.FieldInfo`,用于描述参数信息(不包括参数名)。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `validate` (bool)
|
||||
@@ -30,7 +29,6 @@ description: nonebot.dependencies 模块
|
||||
- **说明:** 依赖注入容器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call`: 依赖注入的可调用对象,可以是任何 Callable 对象
|
||||
|
||||
- `pre_checkers`: 依赖注入解析前的参数检查
|
||||
@@ -44,31 +42,26 @@ description: nonebot.dependencies 模块
|
||||
### _staticmethod_ `parse_params(call, allow_types)` {#Dependent-parse-params}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` (\_DependentCallable[R])
|
||||
|
||||
- `allow_types` (tuple[type[Param], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[[ModelField](../compat.md#ModelField), ...]
|
||||
|
||||
### _staticmethod_ `parse_parameterless(parameterless, allow_types)` {#Dependent-parse-parameterless}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `parameterless` (tuple[Any, ...])
|
||||
|
||||
- `allow_types` (tuple[type[Param], ...])
|
||||
|
||||
- **返回**
|
||||
|
||||
- tuple[Param, ...]
|
||||
|
||||
### _classmethod_ `parse(*, call, parameterless=None, allow_types)` {#Dependent-parse}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` (\_DependentCallable[R])
|
||||
|
||||
- `parameterless` (Iterable[Any] | None)
|
||||
@@ -76,25 +69,20 @@ description: nonebot.dependencies 模块
|
||||
- `allow_types` (Iterable[type[Param]])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Dependent[R]
|
||||
|
||||
### _async method_ `check(**params)` {#Dependent-check}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `**params` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `solve(**params)` {#Dependent-solve}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `**params` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, Any]
|
||||
|
@@ -12,11 +12,9 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 获取可调用对象签名
|
||||
|
||||
- **参数**
|
||||
|
||||
- `call` ((...) -> Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- inspect.Signature
|
||||
|
||||
## _def_ `get_typed_annotation(param, globalns)` {#get-typed-annotation}
|
||||
@@ -24,13 +22,11 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 获取参数的类型注解
|
||||
|
||||
- **参数**
|
||||
|
||||
- `param` (inspect.Parameter)
|
||||
|
||||
- `globalns` (dict[str, Any])
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
||||
## _def_ `check_field_type(field, value)` {#check-field-type}
|
||||
@@ -38,11 +34,9 @@ description: nonebot.dependencies.utils 模块
|
||||
- **说明:** 检查字段类型是否匹配
|
||||
|
||||
- **参数**
|
||||
|
||||
- `field` ([ModelField](../compat.md#ModelField))
|
||||
|
||||
- `value` (Any)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any
|
||||
|
@@ -22,7 +22,6 @@ pip install nonebot2[aiohttp]
|
||||
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -38,23 +37,19 @@ pip install nonebot2[aiohttp]
|
||||
### _async method_ `request(setup)` {#Session-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Session-stream-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- `chunk_size` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[Response](index.md#Response), None]
|
||||
|
||||
### _async method_ `setup()` {#Session-setup}
|
||||
@@ -64,7 +59,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close()` {#Session-close}
|
||||
@@ -74,7 +68,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -88,39 +81,32 @@ pip install nonebot2[aiohttp]
|
||||
### _async method_ `request(setup)` {#Mixin-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Mixin-stream-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- `chunk_size` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[Response](index.md#Response), None]
|
||||
|
||||
### _method_ `websocket(setup)` {#Mixin-websocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](index.md#WebSocket), None]
|
||||
|
||||
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -134,7 +120,6 @@ pip install nonebot2[aiohttp]
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Session
|
||||
|
||||
## _class_ `WebSocket(*, request, session, websocket)` {#WebSocket}
|
||||
@@ -142,7 +127,6 @@ pip install nonebot2[aiohttp]
|
||||
- **说明:** AIOHTTP Websocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` ([Request](index.md#Request))
|
||||
|
||||
- `session` (aiohttp.ClientSession)
|
||||
@@ -156,19 +140,16 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -178,7 +159,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -188,7 +168,6 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -198,33 +177,27 @@ pip install nonebot2[aiohttp]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -92,7 +92,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** FastAPI 驱动框架。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` (NoneBotConfig)
|
||||
@@ -124,21 +123,17 @@ pip install nonebot2[fastapi]
|
||||
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
|
||||
@@ -146,7 +141,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** 使用 `uvicorn` 启动 FastAPI
|
||||
|
||||
- **参数**
|
||||
|
||||
- `host` (str | None)
|
||||
|
||||
- `port` (int | None)
|
||||
@@ -158,7 +152,6 @@ pip install nonebot2[fastapi]
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `FastAPIWebSocket(*, request, websocket)` {#FastAPIWebSocket}
|
||||
@@ -166,7 +159,6 @@ pip install nonebot2[fastapi]
|
||||
- **说明:** FastAPI WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (BaseRequest)
|
||||
|
||||
- `websocket` ([WebSocket](index.md#WebSocket))
|
||||
@@ -178,19 +170,16 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close(code=status.WS_1000_NORMAL_CLOSURE, reason="")` {#FastAPIWebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `receive()` {#FastAPIWebSocket-receive}
|
||||
@@ -200,7 +189,6 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#FastAPIWebSocket-receive-text}
|
||||
@@ -210,7 +198,6 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#FastAPIWebSocket-receive-bytes}
|
||||
@@ -220,25 +207,20 @@ pip install nonebot2[fastapi]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#FastAPIWebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#FastAPIWebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
@@ -22,7 +22,6 @@ pip install nonebot2[httpx]
|
||||
## _class_ `Session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -38,23 +37,19 @@ pip install nonebot2[httpx]
|
||||
### _async method_ `request(setup)` {#Session-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Session-stream-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- `chunk_size` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[Response](index.md#Response), None]
|
||||
|
||||
### _async method_ `setup()` {#Session-setup}
|
||||
@@ -64,7 +59,6 @@ pip install nonebot2[httpx]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `close()` {#Session-close}
|
||||
@@ -74,7 +68,6 @@ pip install nonebot2[httpx]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -88,29 +81,24 @@ pip install nonebot2[httpx]
|
||||
### _async method_ `request(setup)` {#Mixin-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](index.md#Response)
|
||||
|
||||
### _method_ `stream_request(setup, *, chunk_size=1024)` {#Mixin-stream-request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- `chunk_size` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[Response](index.md#Response), None]
|
||||
|
||||
### _method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Mixin-get-session}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -124,13 +112,11 @@ pip install nonebot2[httpx]
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Session
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -40,11 +40,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 设置一个 HTTP 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract method_ `setup_websocket_server(setup)` {#ASGIMixin-setup-websocket-server}
|
||||
@@ -52,23 +50,19 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 设置一个 WebSocket 服务器路由配置
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Cookies(cookies=None)` {#Cookies}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cookies` (CookieTypes)
|
||||
|
||||
### _method_ `set(name, value, domain="", path="/")` {#Cookies-set}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `value` (str)
|
||||
@@ -78,13 +72,11 @@ description: nonebot.drivers 模块
|
||||
- `path` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `get(name, default=None, domain=None, path=None)` {#Cookies-get}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `default` (str | None)
|
||||
@@ -94,13 +86,11 @@ description: nonebot.drivers 模块
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | None
|
||||
|
||||
### _method_ `delete(name, domain=None, path=None)` {#Cookies-delete}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `domain` (str | None)
|
||||
@@ -108,39 +98,32 @@ description: nonebot.drivers 模块
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `clear(domain=None, path=None)` {#Cookies-clear}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `domain` (str | None)
|
||||
|
||||
- `path` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `update(cookies=None)` {#Cookies-update}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cookies` (CookieTypes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `as_header(request)` {#Cookies-as-header}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (Request)
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, str]
|
||||
|
||||
## _abstract class_ `Driver(env, config)` {#Driver}
|
||||
@@ -152,7 +135,6 @@ description: nonebot.drivers 模块
|
||||
驱动器控制框架的启动和停止,适配器的注册,以及机器人生命周期管理。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env)): 包含环境信息的 Env 对象
|
||||
|
||||
- `config` ([Config](../config.md#Config)): 包含配置信息的 Config 对象
|
||||
@@ -180,13 +162,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个协议适配器
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter` (type[[Adapter](../adapters/index.md#Adapter)]): 适配器类
|
||||
|
||||
- `**kwargs`: 其他传递给适配器的参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract property_ `type` {#Driver-type}
|
||||
@@ -206,13 +186,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 启动驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `on_startup(func)` {#Driver-on-startup}
|
||||
@@ -220,11 +198,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个启动时执行的函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
### _method_ `on_shutdown(func)` {#Driver-on-shutdown}
|
||||
@@ -232,11 +208,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 注册一个停止时执行的函数
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` (LIFESPAN_FUNC)
|
||||
|
||||
- **返回**
|
||||
|
||||
- LIFESPAN_FUNC
|
||||
|
||||
### _classmethod_ `on_bot_connect(func)` {#Driver-on-bot-connect}
|
||||
@@ -246,15 +220,12 @@ description: nonebot.drivers 模块
|
||||
装饰一个函数使他在 bot 连接成功时执行。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前连接上的 Bot 对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_BotConnectionHook](../typing.md#T-BotConnectionHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_BotConnectionHook](../typing.md#T-BotConnectionHook)
|
||||
|
||||
### _classmethod_ `on_bot_disconnect(func)` {#Driver-on-bot-disconnect}
|
||||
@@ -264,15 +235,12 @@ description: nonebot.drivers 模块
|
||||
装饰一个函数使他在 bot 连接断开时执行。
|
||||
|
||||
钩子函数参数:
|
||||
|
||||
- bot: 当前连接上的 Bot 对象
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ([T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [T_BotDisconnectionHook](../typing.md#T-BotDisconnectionHook)
|
||||
|
||||
## _var_ `ForwardDriver` {#ForwardDriver}
|
||||
@@ -306,11 +274,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一个 HTTP 请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Response](#Response)
|
||||
|
||||
### _abstract method_ `stream_request(setup, *, chunk_size=1024)` {#HTTPClientMixin-stream-request}
|
||||
@@ -318,13 +284,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一个 HTTP 流式请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- `chunk_size` (int)
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[Response](#Response), None]
|
||||
|
||||
### _abstract method_ `get_session(params=None, headers=None, cookies=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#HTTPClientMixin-get-session}
|
||||
@@ -332,7 +296,6 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 获取一个 HTTP 会话
|
||||
|
||||
- **参数**
|
||||
|
||||
- `params` (QueryTypes)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -346,7 +309,6 @@ description: nonebot.drivers 模块
|
||||
- `proxy` (str | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- HTTPClientSession
|
||||
|
||||
## _class_ `HTTPServerSetup(<auto>)` {#HTTPServerSetup}
|
||||
@@ -362,7 +324,6 @@ description: nonebot.drivers 模块
|
||||
- **参数**
|
||||
|
||||
auto
|
||||
|
||||
- `H10: '1.0'`
|
||||
|
||||
- `H11: '1.1'`
|
||||
@@ -386,7 +347,6 @@ description: nonebot.drivers 模块
|
||||
## _class_ `Request(method, url, *, params=None, headers=None, cookies=None, content=None, data=None, json=None, files=None, version=HTTPVersion.H11, timeout=None, proxy=None)` {#Request}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `method` (str | bytes)
|
||||
|
||||
- `url` (URL | str | RawURL)
|
||||
@@ -414,7 +374,6 @@ description: nonebot.drivers 模块
|
||||
## _class_ `Response(status_code, *, headers=None, content=None, request=None)` {#Response}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `status_code` (int)
|
||||
|
||||
- `headers` (HeaderTypes)
|
||||
@@ -452,7 +411,6 @@ description: nonebot.drivers 模块
|
||||
## _abstract class_ `WebSocket(*, request)` {#WebSocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (Request)
|
||||
|
||||
### _abstract property_ `closed` {#WebSocket-closed}
|
||||
@@ -470,7 +428,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
@@ -478,13 +435,11 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 关闭 WebSocket 连接请求
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -496,7 +451,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _abstract async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -508,7 +462,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _abstract async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -520,7 +473,6 @@ description: nonebot.drivers 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send(data)` {#WebSocket-send}
|
||||
@@ -528,11 +480,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket text/bytes 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str | bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
@@ -540,11 +490,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket text 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _abstract async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
@@ -552,11 +500,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发送一条 WebSocket binary 信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _abstract class_ `WebSocketClientMixin(<auto>)` {#WebSocketClientMixin}
|
||||
@@ -572,11 +518,9 @@ description: nonebot.drivers 模块
|
||||
- **说明:** 发起一个 WebSocket 连接
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](#WebSocket), None]
|
||||
|
||||
## _class_ `WebSocketServerSetup(<auto>)` {#WebSocketServerSetup}
|
||||
@@ -594,19 +538,14 @@ description: nonebot.drivers 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(driver) -> type[D]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` (type[D])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[D]
|
||||
|
||||
**2.** `(driver, __m, /, *mixins) -> type[CombinedDriver]`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `driver` (type[D])
|
||||
|
||||
- `__m` (type[[Mixin](#Mixin)])
|
||||
@@ -614,5 +553,4 @@ description: nonebot.drivers 模块
|
||||
- `*mixins` (type[[Mixin](#Mixin)])
|
||||
|
||||
- **返回**
|
||||
|
||||
- type[CombinedDriver]
|
||||
|
@@ -18,7 +18,6 @@ None 驱动适配
|
||||
- **说明:** None 驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
@@ -40,13 +39,11 @@ None 驱动适配
|
||||
- **说明:** 启动 none driver
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args`
|
||||
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `exit(force=False)` {#Driver-exit}
|
||||
@@ -54,9 +51,7 @@ None 驱动适配
|
||||
- **说明:** 退出 none driver
|
||||
|
||||
- **参数**
|
||||
|
||||
- `force` (bool): 强制退出
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
@@ -68,7 +68,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** Quart 驱动框架
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` (NoneBotConfig)
|
||||
@@ -100,21 +99,17 @@ pip install nonebot2[quart]
|
||||
### _method_ `setup_http_server(setup)` {#Driver-setup-http-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([HTTPServerSetup](index.md#HTTPServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _method_ `setup_websocket_server(setup)` {#Driver-setup-websocket-server}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([WebSocketServerSetup](index.md#WebSocketServerSetup))
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _method_ `run(host=None, port=None, *args, app=None, **kwargs)` {#Driver-run}
|
||||
@@ -122,7 +117,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** 使用 `uvicorn` 启动 Quart
|
||||
|
||||
- **参数**
|
||||
|
||||
- `host` (str | None)
|
||||
|
||||
- `port` (int | None)
|
||||
@@ -134,7 +128,6 @@ pip install nonebot2[quart]
|
||||
- `**kwargs`
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
## _class_ `WebSocket(*, request, websocket_ctx)` {#WebSocket}
|
||||
@@ -142,7 +135,6 @@ pip install nonebot2[quart]
|
||||
- **说明:** Quart WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` (BaseRequest)
|
||||
|
||||
- `websocket_ctx` (WebsocketContext)
|
||||
@@ -154,19 +146,16 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -176,7 +165,6 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -186,7 +174,6 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -196,25 +183,20 @@ pip install nonebot2[quart]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
@@ -22,11 +22,9 @@ pip install nonebot2[websockets]
|
||||
## _def_ `catch_closed(func)` {#catch-closed}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `func` ((P) -> CoroutineType[Any, Any, T])
|
||||
|
||||
- **返回**
|
||||
|
||||
- (P) -> CoroutineType[Any, Any, T]
|
||||
|
||||
## _class_ `Mixin(<auto>)` {#Mixin}
|
||||
@@ -40,11 +38,9 @@ pip install nonebot2[websockets]
|
||||
### _method_ `websocket(setup)` {#Mixin-websocket}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `setup` ([Request](index.md#Request))
|
||||
|
||||
- **返回**
|
||||
|
||||
- AsyncGenerator[[WebSocket](index.md#WebSocket), None]
|
||||
|
||||
## _class_ `WebSocket(*, request, websocket)` {#WebSocket}
|
||||
@@ -52,7 +48,6 @@ pip install nonebot2[websockets]
|
||||
- **说明:** Websockets WebSocket Wrapper
|
||||
|
||||
- **参数**
|
||||
|
||||
- `request` ([Request](index.md#Request))
|
||||
|
||||
- `websocket` (ClientConnection)
|
||||
@@ -64,19 +59,16 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `close(code=1000, reason="")` {#WebSocket-close}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `code` (int)
|
||||
|
||||
- `reason` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- untyped
|
||||
|
||||
### _async method_ `receive()` {#WebSocket-receive}
|
||||
@@ -86,7 +78,6 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str | bytes
|
||||
|
||||
### _async method_ `receive_text()` {#WebSocket-receive-text}
|
||||
@@ -96,7 +87,6 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- str
|
||||
|
||||
### _async method_ `receive_bytes()` {#WebSocket-receive-bytes}
|
||||
@@ -106,33 +96,27 @@ pip install nonebot2[websockets]
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- bytes
|
||||
|
||||
### _async method_ `send_text(data)` {#WebSocket-send-text}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
### _async method_ `send_bytes(data)` {#WebSocket-send-bytes}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `data` (bytes)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
## _class_ `Driver(env, config)` {#Driver}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `env` ([Env](../config.md#Env))
|
||||
|
||||
- `config` ([Config](../config.md#Config))
|
||||
|
@@ -62,7 +62,6 @@ NoneBotException
|
||||
- **说明:** 指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `reason`: 忽略事件的原因
|
||||
|
||||
## _class_ `SkippedException(<auto>)` {#SkippedException}
|
||||
@@ -101,7 +100,6 @@ NoneBotException
|
||||
- **说明:** 指示 NoneBot 阻止本次 API 调用或修改本次调用返回值,并返回自定义内容。 可由 api hook 抛出。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `result`: 返回的内容
|
||||
|
||||
## _class_ `StopPropagation(<auto>)` {#StopPropagation}
|
||||
@@ -200,7 +198,6 @@ NoneBotException
|
||||
- **说明:** 代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `adapter_name`: 标识 adapter
|
||||
|
||||
## _class_ `NoLogException(<auto>)` {#NoLogException}
|
||||
|
@@ -60,11 +60,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Driver](drivers/index.md#Driver): 全局 [Driver](drivers/index.md#Driver) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -80,27 +78,20 @@ description: nonebot 模块
|
||||
- **重载**
|
||||
|
||||
**1.** `(name) -> Adapter`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 适配器名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Adapter](adapters/index.md#Adapter): 指定名称的 [Adapter](adapters/index.md#Adapter) 对象
|
||||
|
||||
**2.** `(name) -> A`
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (type[A]): 适配器类型
|
||||
|
||||
- **返回**
|
||||
|
||||
- A: 指定类型的 [Adapter](adapters/index.md#Adapter) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 指定的 [Adapter](adapters/index.md#Adapter) 未注册
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -121,11 +112,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, [Adapter](adapters/index.md#Adapter)]: 所有 [Adapter](adapters/index.md#Adapter) 实例字典
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -143,11 +132,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any: Server App 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -167,11 +154,9 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- Any: ASGI 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- AssertionError: 全局 Driver 对象不是 [ASGIMixin](drivers/index.md#ASGIMixin) 类型
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
@@ -192,15 +177,12 @@ description: nonebot 模块
|
||||
当不提供时,返回一个 [Bot](adapters/index.md#Bot)。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `self_id` (str | None): 用来识别 [Bot](adapters/index.md#Bot) 的 [Bot.self_id](adapters/index.md#Bot-self-id) 属性
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Bot](adapters/index.md#Bot): [Bot](adapters/index.md#Bot) 对象
|
||||
|
||||
- **异常**
|
||||
|
||||
- KeyError: 对应 self_id 的 Bot 不存在
|
||||
|
||||
- ValueError: 没有传入 self_id 且没有 Bot 可用
|
||||
@@ -224,13 +206,11 @@ description: nonebot 模块
|
||||
empty
|
||||
|
||||
- **返回**
|
||||
|
||||
- dict[str, [Bot](adapters/index.md#Bot)]: 一个以 [Bot.self_id](adapters/index.md#Bot-self-id) 为键
|
||||
|
||||
[Bot](adapters/index.md#Bot) 对象为值的字典
|
||||
|
||||
- **异常**
|
||||
|
||||
- ValueError: 全局 [Driver](drivers/index.md#Driver) 对象尚未初始化 ([nonebot.init](#init) 尚未调用)
|
||||
|
||||
- **用法**
|
||||
@@ -250,13 +230,11 @@ description: nonebot 模块
|
||||
也可以传入自定义的 `_env_file` 来指定 NoneBot 从该文件读取配置。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `_env_file` (DOTENV_TYPE | None): 配置文件名,默认从 `.env.{env_name}` 中读取配置
|
||||
|
||||
- `**kwargs` (Any): 任意变量,将会存储到 [Driver.config](drivers/index.md#Driver-config) 对象里
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
@@ -270,13 +248,11 @@ description: nonebot 模块
|
||||
- **说明:** 启动 NoneBot,即运行全局 [Driver](drivers/index.md#Driver) 对象。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*args` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的位置参数
|
||||
|
||||
- `**kwargs` (Any): 传入 [Driver.run](drivers/index.md#Driver-run) 的命名参数
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
||||
|
||||
- **用法**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user