Compare commits

...

82 Commits

Author SHA1 Message Date
N791
d8c36e8eff 🍻 publish plugin nonebot-plugin-ehentai-search (#2884) 2024-08-17 10:48:42 +08:00
noneflow[bot]
1cc5d1af33 📝 Update changelog 2024-08-16 13:27:05 +00:00
shengwang52005
88074cf5c3 🍻 publish plugin pokepoke_miss (#2878) 2024-08-16 13:25:54 +00:00
noneflow[bot]
5d637eed95 📝 Update changelog 2024-08-15 03:35:09 +00:00
lm175
362c43ce5f 🍻 publish plugin 聊天截图伪造 (#2879) 2024-08-15 03:34:08 +00:00
noneflow[bot]
622b8eb51e 📝 Update changelog 2024-08-13 11:23:45 +00:00
hanasa2023
c369dcf781 🍻 publish plugin ba-tools (#2863) 2024-08-13 11:22:46 +00:00
noneflow[bot]
53d1e1dee9 📝 Update changelog 2024-08-13 07:39:10 +00:00
Leo Q
75f5825cff 📝 Docs: 添加 Windows Powershell 设置环境变量方法 (#2874)
Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
2024-08-13 15:38:17 +08:00
noneflow[bot]
d05c90787c 📝 Update changelog 2024-08-12 15:23:00 +00:00
BEISNWKZNAN
e07ba36a4a 🍻 publish plugin 精华消息管理 (#2872) 2024-08-12 15:22:10 +00:00
noneflow[bot]
f7c05d9a08 📝 Update changelog 2024-08-11 15:24:59 +00:00
kawaiior
59c5a1a35d 🍻 publish plugin B站收藏夹监视器 (#2868) 2024-08-11 15:24:07 +00:00
noneflow[bot]
3eb653821e 📝 Update changelog 2024-08-11 12:47:36 +00:00
Ju4tCode
214bc838c2 📝 Docs: 更新 localstore 插件文档 (#2871) 2024-08-11 20:46:41 +08:00
noneflow[bot]
79c7ea5bab 📝 Update changelog 2024-08-11 07:17:00 +00:00
Ju4tCode
b59b1be6ff Feature: 优化依赖注入在 pydantic v2 下的性能 (#2870) 2024-08-11 15:15:59 +08:00
noneflow[bot]
aeb75a6ce3 📝 Update changelog 2024-08-11 07:05:13 +00:00
iam57ao
847325a119 🍻 publish plugin Alist (#2864) 2024-08-11 07:04:22 +00:00
noneflow[bot]
26eabfaf6f 📝 Update changelog 2024-08-09 12:18:53 +00:00
月ヶ瀬
40a7b97220 ✏️ Plugin: 修改插件 system-command 信息 (#2862)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-09 20:18:01 +08:00
noneflow[bot]
91b40748c4 📝 Update changelog 2024-08-09 12:14:40 +00:00
SamuNatsu
013a2f94d6 🍻 publish plugin nonebot-plugin-deer-pipe (#2858) 2024-08-09 12:13:51 +00:00
noneflow[bot]
74d280ed75 📝 Update changelog 2024-08-08 09:04:11 +00:00
luosheng520qaq
b7d46de10e 🍻 publish plugin 漂流瓶 (#2860) 2024-08-08 09:03:15 +00:00
noneflow[bot]
c37b5bbbca 📝 Update changelog 2024-08-07 13:11:34 +00:00
zhongwen-4
5e08e73698 🍻 publish plugin 奇怪的小功能 (#2850) 2024-08-07 13:10:40 +00:00
pre-commit-ci[bot]
b27bb92d03 ⬆️ auto update by pre-commit hooks (#2857)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-06 14:43:44 +08:00
noneflow[bot]
6bf8858cc6 📝 Update changelog 2024-08-06 06:20:30 +00:00
Ju4tCode
c97a780645 Feature: 添加遗漏的类型标注 (#2856) 2024-08-06 14:19:17 +08:00
noneflow[bot]
976c1cd8e0 📝 Update changelog 2024-08-03 13:21:57 +00:00
ALittleBot
26fd6f8a6c ✏️ Plugin: 修改 nonebot-plugin-fishing 插件作者 (#2854) 2024-08-03 21:20:57 +08:00
noneflow[bot]
0020ad28ba 📝 Update changelog 2024-08-03 09:53:27 +00:00
CCYellowStar2
ba9ca63f10 🍻 publish plugin SunoAI音乐生成 (#2852) 2024-08-03 09:52:24 +00:00
noneflow[bot]
28b5b732c2 📝 Update changelog 2024-07-29 12:38:05 +00:00
KomoriDev
b944da8445 🍻 publish plugin 谁是卷王 (#2848) 2024-07-29 12:37:02 +00:00
noneflow[bot]
5cab166d6b 📝 Update changelog 2024-07-28 15:04:05 +00:00
zhaomaoniu
546cdb4229 🍻 publish plugin GPT-SoVITS 语音合成 (#2846) 2024-07-28 15:02:59 +00:00
noneflow[bot]
77790fad1f 📝 Update changelog 2024-07-28 12:41:01 +00:00
Alpaca4610
bcf849c98f 🍻 publish plugin 基于清影的AI视频生成 (#2842) 2024-07-28 12:40:00 +00:00
noneflow[bot]
f7b3c8af02 📝 Update changelog 2024-07-26 03:42:50 +00:00
tkgs0
cced60589c 🍻 publish plugin 命令行 (#2839) 2024-07-26 03:41:42 +00:00
noneflow[bot]
62adb32c94 📝 Update changelog 2024-07-22 07:10:44 +00:00
Lonely-Sails
6ab752dcdb ✏️ Bot: 更新 Minecraft QQBot 信息 (#2838) 2024-07-22 15:09:31 +08:00
noneflow[bot]
4d6f071739 📝 Update changelog 2024-07-21 14:58:12 +00:00
wyf7685
bd140c2ceb 🍻 publish plugin exe_code (#2834) 2024-07-21 14:57:09 +00:00
noneflow[bot]
59d9991aa4 📝 Update changelog 2024-07-21 12:56:40 +00:00
Lonely-Sails
55e7f59e40 🍻 publish bot Minecraft_QQBot (#2836) 2024-07-21 12:55:37 +00:00
noneflow[bot]
bb83483020 📝 Update changelog 2024-07-21 12:36:25 +00:00
This-is-XiaoDeng
5300ef5119 🍻 publish plugin nonebot-plugin-autopush (#2832) 2024-07-21 12:35:17 +00:00
noneflow[bot]
5a50d4203c 📝 Update changelog 2024-07-21 10:07:54 +00:00
SwedishDoveCooker
01a96f3086 🍻 publish plugin vv_helper (#2820) 2024-07-21 10:06:53 +00:00
noneflow[bot]
0570d779ee 📝 Update changelog 2024-07-21 04:51:31 +00:00
Cvandia
18d0bc2c81 🍻 publish plugin nonebot_plugin_game_torrent (#2826) 2024-07-21 04:50:31 +00:00
Ju4tCode
87e0d8148f 👷 Fix: preview alias and commit status (#2831) 2024-07-21 12:40:50 +08:00
Ju4tCode
53d8989145 🐛 Fix: website preview CD (#2830) 2024-07-21 12:14:18 +08:00
noneflow[bot]
5433b4ebdf 📝 Update changelog 2024-07-21 03:29:14 +00:00
wyeeeee
f10cecf16a 🍻 publish plugin 每日油价 (#2821) 2024-07-21 03:28:10 +00:00
Ju4tCode
60a3f6f4cc 👷 Security: 拆分 PR Website CI/CD (#2829) 2024-07-21 11:23:15 +08:00
noneflow[bot]
f70ae89098 📝 Update changelog 2024-07-20 06:04:34 +00:00
Ju4tCode
2f60c5e9b4 🚨 Fix: 错误的类型标注和 annotated 处理 (#2828) 2024-07-20 14:03:32 +08:00
noneflow[bot]
015ddd9517 📝 Update changelog 2024-07-18 15:18:51 +00:00
StarXinXin
f1539d9ec4 🍻 publish bot 星辰 Bot (#2823) 2024-07-18 15:17:48 +00:00
noneflow[bot]
2d0444ba75 📝 Update changelog 2024-07-18 13:35:13 +00:00
shiyihang2007
ed2c222e83 🍻 publish plugin wordle (#2817) 2024-07-18 13:34:08 +00:00
noneflow[bot]
ed048913a4 📝 Update changelog 2024-07-17 15:07:06 +00:00
SuperGuGuGu
121ba17698 ✏️ Plugin: 移除 kanonbot 插件 (#2819) 2024-07-17 23:05:55 +08:00
noneflow[bot]
d0f5a76c47 📝 Update changelog 2024-07-15 14:21:24 +00:00
NCBM
f809f1d089 🍻 publish plugin 再润 (#2815) 2024-07-15 14:20:12 +00:00
noneflow[bot]
070ad18781 📝 Update changelog 2024-07-13 13:10:45 +00:00
Shenyi Chen
56119ef1cc ✏️ Plugin: 更新插件 sparkapi 信息 (#2812) 2024-07-13 21:09:41 +08:00
noneflow[bot]
30195a35dc 📝 Update changelog 2024-07-13 12:07:10 +00:00
Asankilp
0500b7baab 🍻 publish plugin 漫展/展览查询 (#2810) 2024-07-13 12:06:04 +00:00
noneflow[bot]
08473a5c25 📝 Update changelog 2024-07-11 09:47:40 +00:00
Lumine
37ad14c277 ✏️ Plugin: 修改插件 miragetank & charpic 信息 (#2807) 2024-07-11 17:46:41 +08:00
noneflow[bot]
3e8c6ce541 📝 Update changelog 2024-07-11 09:41:38 +00:00
shi-yingyingjiang
3dd5539dc7 🍻 publish plugin 鸣潮wiki (#2801) 2024-07-11 09:40:36 +00:00
noneflow[bot]
559a0320a8 📝 Update changelog 2024-07-11 09:34:58 +00:00
1v7w
8646d885f0 🍻 publish plugin cloudfare R2 客服端 (#2805) 2024-07-11 09:33:53 +00:00
noneflow[bot]
84c008cdce 📝 Update changelog 2024-07-10 13:41:24 +00:00
QuickLAW
2671cb5b72 🍻 publish plugin AnyMate小助手 (#2760) 2024-07-10 13:40:12 +00:00
noneflow[bot]
379440708f 📝 Update changelog 2024-07-06 12:54:50 +00:00
23 changed files with 865 additions and 200 deletions

View File

@@ -0,0 +1,99 @@
name: Site Deploy (Preview CD)
on:
workflow_run:
workflows: ["Site Deploy (Preview CI)"]
types:
- completed
jobs:
preview-cd:
runs-on: ubuntu-latest
concurrency:
group: pull-request-preview-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment: pull request
permissions:
actions: read
statuses: write
pull-requests: write
steps:
- name: Set Commit Status
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.workflow_run.head_sha,
context: 'Website Preview',
description: 'Deploying...',
state: 'pending',
})
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: website-preview
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Restore Context
run: |
cat action.env >> $GITHUB_ENV
- name: Set Deploy Name
run: |
echo "DEPLOY_NAME=deploy-preview-${{ env.PR_NUMBER }}" >> $GITHUB_ENV
- name: Deploy to Netlify
id: deploy
uses: nwtgck/actions-netlify@v3
with:
publish-dir: ./website/build
production-deploy: false
deploy-message: "Deploy ${{ env.DEPLOY_NAME }}@${{ github.event.workflow_run.head_sha }}"
alias: ${{ env.DEPLOY_NAME }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.SITE_ID }}
# action netlify has no pull request context, so we need to comment by ourselves
- name: Comment on Pull Request
uses: marocchino/sticky-pull-request-comment@v2
with:
header: website
number: ${{ env.PR_NUMBER }}
message: |
:rocket: Deployed to ${{ steps.deploy.outputs.deploy-url }}
- name: Set Commit Status
uses: actions/github-script@v7
if: always()
with:
script: |
if (`${{ job.status }}` === 'success') {
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.workflow_run.head_sha,
context: 'Website Preview',
description: `Deployed to ${{ steps.deploy.outputs.deploy-url }}`,
state: 'success',
target_url: `${{ steps.deploy.outputs.deploy-url }}`,
})
} else {
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.workflow_run.head_sha,
context: 'Website Preview',
description: `Deploy ${{ job.status }}`,
state: 'failure',
})
}

View File

@@ -0,0 +1,42 @@
name: Site Deploy (Preview CI)
on:
pull_request:
jobs:
preview-ci:
runs-on: ubuntu-latest
concurrency:
group: pull-request-preview-${{ github.event.number }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup Python Environment
uses: ./.github/actions/setup-python
- name: Setup Node Environment
uses: ./.github/actions/setup-node
- name: Build API Doc
uses: ./.github/actions/build-api-doc
- name: Build Doc
run: yarn build
- name: Export Context
run: |
echo "PR_NUMBER=${{ github.event.number }}" >> ./action.env
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: website-preview
path: |
./website/build
./action.env
retention-days: 1

View File

@@ -1,46 +0,0 @@
name: Site Deploy(Preview)
on:
pull_request_target:
jobs:
preview:
runs-on: ubuntu-latest
concurrency:
group: pull-request-preview-${{ github.event.number }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup Python Environment
uses: ./.github/actions/setup-python
- name: Setup Node Environment
uses: ./.github/actions/setup-node
- name: Build API Doc
uses: ./.github/actions/build-api-doc
- name: Build Doc
run: yarn build
- name: Get Deploy Name
run: |
echo "DEPLOY_NAME=deploy-preview-${{ github.event.number }}" >> $GITHUB_ENV
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3
with:
publish-dir: "./website/build"
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy ${{ env.DEPLOY_NAME }}@${{ github.sha }}"
enable-commit-comment: false
alias: ${{ env.DEPLOY_NAME }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.SITE_ID }}

View File

@@ -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.5.0
rev: v0.5.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
@@ -20,7 +20,7 @@ repos:
stages: [commit]
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
stages: [commit]

View File

@@ -607,5 +607,30 @@
}
],
"is_official": false
},
{
"name": "星辰 Bot",
"desc": "欢迎使用 星辰 Bot 项目!这是一款基于 NoneBot2 打造的智能 QQ 机器人旨在为用户提供丰富的功能体验。无论是获取一言的灵感探索历史上的今天还是穿梭60s世界星辰 Bot 为您打开了全新的交流之门。快来尝试吧!",
"author": "StarXinXin",
"homepage": "https://github.com/StarXinXin/StarsBot",
"tags": [],
"is_official": false
},
{
"name": "Minecraft_QQBot",
"desc": "基于 NoneBot2 的 Minecraft 群服互联 QQ 机器人,支持多服务器多种方式连接。",
"author": "Lonely-Sails",
"homepage": "https://github.com/Minecraft-QQBot/BotServer",
"tags": [
{
"label": "Minecraft",
"color": "#ea5252"
},
{
"label": "娱乐",
"color": "#37a7e7"
}
],
"is_official": false
}
]

View File

@@ -855,15 +855,33 @@
{
"module_name": "nonebot_plugin_charpic",
"project_link": "nonebot-plugin-charpic",
"author": "RafuiiChan",
"tags": [],
"author": "1umine",
"tags": [
{
"label": "字符画",
"color": "#ea5252"
},
{
"label": "多平台适配",
"color": "#ea5252"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_miragetank",
"project_link": "nonebot-plugin-miragetank",
"author": "RafuiiChan",
"tags": [],
"author": "1umine",
"tags": [
{
"label": "幻影坦克",
"color": "#ea5252"
},
{
"label": "多平台适配",
"color": "#ea5252"
}
],
"is_official": false
},
{
@@ -4554,18 +4572,6 @@
],
"is_official": false
},
{
"module_name": "nonebot_plugin_kanonbot",
"project_link": "nonebot-plugin-kanonbot",
"author": "SuperGuGuGu",
"tags": [
{
"label": "KanonBot",
"color": "#44ddff"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_mcversion",
"project_link": "nonebot-plugin-mcversion",
@@ -5563,7 +5569,7 @@
{
"module_name": "nonebot_plugin_fishing",
"project_link": "nonebot-plugin-fishing",
"author": "C14H22O",
"author": "ALittleBot",
"tags": [
{
"label": "钓鱼",
@@ -6022,6 +6028,14 @@
{
"label": "AI",
"color": "#00ff00"
},
{
"label": "星火",
"color": "#0000ff"
},
{
"label": "Chat",
"color": "#ff0000"
}
],
"is_official": false
@@ -6418,5 +6432,285 @@
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_anymate",
"project_link": "nonebot-plugin-anymate",
"author": "QuickLAW",
"tags": [
{
"label": "server",
"color": "#ea5252"
},
{
"label": "func",
"color": "#ea5252"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_cfr2",
"project_link": "nonebot-plugin-cfr2",
"author": "1v7w",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_WWwiki",
"project_link": "nonebot-plugin-WWwiki",
"author": "shi-yingyingjiang",
"tags": [
{
"label": "鸣潮",
"color": "#ea5252"
},
{
"label": "wiki",
"color": "#30af29"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_acgnshow",
"project_link": "nonebot-plugin-acgnshow",
"author": "Asankilp",
"tags": [
{
"label": "bilibili",
"color": "#f21010"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_runagain",
"project_link": "nonebot-plugin-runagain",
"author": "NCBM",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_wordle_simple",
"project_link": "nonebot-plugin-wordle-simple",
"author": "shiyihang2007",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_daily_oil_price",
"project_link": "nonebot-plugin-daily-oil-price",
"author": "wyeeeee",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_game_torrent",
"project_link": "nonebot-plugin-game-torrent",
"author": "Cvandia",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_weiweibot",
"project_link": "nonebot-plugin-weiweibot",
"author": "SwedishDoveCooker",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_autopush",
"project_link": "nonebot-plugin-autopush",
"author": "This-is-XiaoDeng",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_exe_code",
"project_link": "nonebot-plugin-exe-code",
"author": "wyf7685",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_system_command",
"project_link": "nonebot-plugin-system-command",
"author": "tkgs0",
"tags": [
{
"label": "shell",
"color": "#0078d4"
},
{
"label": "cmd",
"color": "#24292f"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_cogvideox",
"project_link": "nonebot-plugin-cogvideox",
"author": "Alpaca4610",
"tags": [
{
"label": "AI",
"color": "#ea5252"
},
{
"label": "视频生成",
"color": "#1a30b7"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_gpt_sovits",
"project_link": "nonebot-plugin-gpt-sovits",
"author": "zhaomaoniu",
"tags": [
{
"label": "GPT-SoVITS",
"color": "#000000"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_wakatime",
"project_link": "nonebot-plugin-wakatime",
"author": "KomoriDev",
"tags": [
{
"label": "WakaTime",
"color": "#000000"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_sunoai",
"project_link": "nonebot-plugin-sunoai",
"author": "CCYellowStar2",
"tags": [
{
"label": "SunoAi",
"color": "#ea5252"
},
{
"label": "AI歌曲",
"color": "#ea5252"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_function",
"project_link": "nonebot-plugin-function",
"author": "zhongwen-4",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_web_bottle",
"project_link": "nonebot-plugin-web-bottle",
"author": "luosheng520qaq",
"tags": [
{
"label": "漂流瓶",
"color": "#689dd0"
},
{
"label": "审核",
"color": "#e3567b"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_deer_pipe",
"project_link": "nonebot-plugin-deer-pipe",
"author": "SamuNatsu",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_alist",
"project_link": "nonebot-plugin-alist",
"author": "iam57ao",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_bili_fav_watcher",
"project_link": "nonebot-plugin-bili-fav-watcher",
"author": "kawaiior",
"tags": [
{
"label": "bilibili",
"color": "#ea5252"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_essence_message",
"project_link": "nonebot-plugin-essence-message",
"author": "BEISNWKZNAN",
"tags": [],
"is_official": false
},
{
"module_name": "nonebot_plugin_ba_tools",
"project_link": "nonebot-plugin-ba-tools",
"author": "hanasa2023",
"tags": [
{
"label": "蔚蓝档案",
"color": "#00fcf8"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_fakepic",
"project_link": "nonebot-plugin-fakepic",
"author": "lm175",
"tags": [
{
"label": "图片生成",
"color": "#3a82ff"
}
],
"is_official": false
},
{
"module_name": "pokepoke_miss",
"project_link": "pokepoke-miss",
"author": "shengwang52005",
"tags": [
{
"label": "舞萌",
"color": "#f7fe0e"
},
{
"label": "戳一戳",
"color": "#e80606"
}
],
"is_official": false
},
{
"module_name": "nonebot_plugin_ehentai_search",
"project_link": "nonebot-plugin-ehentai-search",
"author": "N791",
"tags": [
{
"label": "ehentai",
"color": "#ffe700"
}
],
"is_official": false
}
]

View File

@@ -8,17 +8,20 @@ FrontMatter:
"""
from collections.abc import Generator
from functools import cached_property
from dataclasses import dataclass, is_dataclass
from typing_extensions import Self, get_args, get_origin, is_typeddict
from typing import (
TYPE_CHECKING,
Any,
Union,
Generic,
TypeVar,
Callable,
Optional,
Protocol,
Annotated,
overload,
)
from pydantic import VERSION, BaseModel
@@ -46,8 +49,8 @@ __all__ = (
"DEFAULT_CONFIG",
"FieldInfo",
"ModelField",
"TypeAdapter",
"extract_field_info",
"model_field_validate",
"model_fields",
"model_config",
"model_dump",
@@ -63,9 +66,10 @@ __autodoc__ = {
if PYDANTIC_V2: # pragma: pydantic-v2
from pydantic import GetCoreSchemaHandler
from pydantic import TypeAdapter as TypeAdapter
from pydantic_core import CoreSchema, core_schema
from pydantic._internal._repr import display_as_type
from pydantic import TypeAdapter, GetCoreSchemaHandler
from pydantic.fields import FieldInfo as BaseFieldInfo
Required = Ellipsis
@@ -125,6 +129,25 @@ if PYDANTIC_V2: # pragma: pydantic-v2
"""Construct a ModelField from given infos."""
return cls._construct(name, annotation, field_info or FieldInfo())
def __hash__(self) -> int:
# Each ModelField is unique for our purposes,
# to allow store them in a set.
return id(self)
@cached_property
def type_adapter(self) -> TypeAdapter:
"""TypeAdapter of the field.
Cache the TypeAdapter to avoid creating it multiple times.
Pydantic v2 uses too much cpu time to create TypeAdapter.
See: https://github.com/pydantic/pydantic/issues/9834
"""
return TypeAdapter(
Annotated[self.annotation, self.field_info],
config=None if self._annotation_has_config() else DEFAULT_CONFIG,
)
def _annotation_has_config(self) -> bool:
"""Check if the annotation has config.
@@ -152,10 +175,9 @@ if PYDANTIC_V2: # pragma: pydantic-v2
"""Get the display of the type of the field."""
return display_as_type(self.annotation)
def __hash__(self) -> int:
# Each ModelField is unique for our purposes,
# to allow store them in a set.
return id(self)
def validate_value(self, value: Any) -> Any:
"""Validate the value pass to the field."""
return self.type_adapter.validate_python(value)
def extract_field_info(field_info: BaseFieldInfo) -> dict[str, Any]:
"""Get FieldInfo init kwargs from a FieldInfo instance."""
@@ -164,15 +186,6 @@ if PYDANTIC_V2: # pragma: pydantic-v2
kwargs["annotation"] = field_info.rebuild_annotation()
return kwargs
def model_field_validate(
model_field: ModelField, value: Any, config: Optional[ConfigDict] = None
) -> Any:
"""Validate the value pass to the field."""
type: Any = Annotated[model_field.annotation, model_field.field_info]
return TypeAdapter(
type, config=None if model_field._annotation_has_config() else config
).validate_python(value)
def model_fields(model: type[BaseModel]) -> list[ModelField]:
"""Get field list of a model."""
@@ -305,6 +318,45 @@ else: # pragma: pydantic-v1
)
return cls._construct(name, annotation, field_info or FieldInfo())
def validate_value(self, value: Any) -> Any:
"""Validate the value pass to the field."""
v, errs_ = self.validate(value, {}, loc=())
if errs_:
raise ValueError(value, self)
return v
class TypeAdapter(Generic[T]):
@overload
def __init__(
self,
type: type[T],
*,
config: Optional[ConfigDict] = ...,
) -> None: ...
@overload
def __init__(
self,
type: Any,
*,
config: Optional[ConfigDict] = ...,
) -> None: ...
def __init__(
self,
type: Any,
*,
config: Optional[ConfigDict] = None,
) -> None:
self.type = type
self.config = config
def validate_python(self, value: Any) -> T:
return type_validate_python(self.type, value)
def validate_json(self, value: Union[str, bytes]) -> T:
return type_validate_json(self.type, value)
def extract_field_info(field_info: BaseFieldInfo) -> dict[str, Any]:
"""Get FieldInfo init kwargs from a FieldInfo instance."""
@@ -314,22 +366,6 @@ else: # pragma: pydantic-v1
kwargs.update(field_info.extra)
return kwargs
def model_field_validate(
model_field: ModelField, value: Any, config: Optional[type[ConfigDict]] = None
) -> Any:
"""Validate the value pass to the field.
Set config before validate to ensure validate correctly.
"""
if model_field.model_config is not config:
model_field.set_config(config or ConfigDict)
v, errs_ = model_field.validate(value, {}, loc=())
if errs_:
raise ValueError(value, model_field)
return v
def model_fields(model: type[BaseModel]) -> list[ModelField]:
"""Get field list of a model."""

View File

@@ -9,9 +9,9 @@ from typing import Any, Callable, ForwardRef
from loguru import logger
from nonebot.compat import ModelField
from nonebot.exception import TypeMisMatch
from nonebot.typing import evaluate_forwardref
from nonebot.compat import DEFAULT_CONFIG, ModelField, model_field_validate
def get_typed_signature(call: Callable[..., Any]) -> inspect.Signature:
@@ -51,6 +51,6 @@ def check_field_type(field: ModelField, value: Any) -> Any:
"""检查字段类型是否匹配"""
try:
return model_field_validate(field, value, DEFAULT_CONFIG)
return field.validate_value(value)
except ValueError:
raise TypeMisMatch(field, value)

View File

@@ -15,7 +15,7 @@ def combine_driver(driver: type[D]) -> type[D]: ...
@overload
def combine_driver(
driver: type[D], _m: type[Mixin], *mixins: type[Mixin]
driver: type[D], __m: type[Mixin], /, *mixins: type[Mixin]
) -> type["CombinedDriver"]: ...

View File

@@ -76,7 +76,7 @@ T = TypeVar("T")
current_bot: ContextVar[Bot] = ContextVar("current_bot")
current_event: ContextVar[Event] = ContextVar("current_event")
current_matcher: ContextVar["Matcher"] = ContextVar("current_matcher")
current_handler: ContextVar[Dependent] = ContextVar("current_handler")
current_handler: ContextVar[Dependent[Any]] = ContextVar("current_handler")
@dataclass

View File

@@ -102,7 +102,7 @@ class DependParam(Param):
"""
def __init__(
self, *args, dependent: Dependent, use_cache: bool, **kwargs: Any
self, *args, dependent: Dependent[Any], use_cache: bool, **kwargs: Any
) -> None:
super().__init__(*args, **kwargs)
self.dependent = dependent
@@ -114,7 +114,7 @@ class DependParam(Param):
@classmethod
def _from_field(
cls,
sub_dependent: Dependent,
sub_dependent: Dependent[Any],
use_cache: bool,
validate: Union[bool, PydanticFieldInfo],
) -> Self:
@@ -190,7 +190,7 @@ class DependParam(Param):
use_cache: bool = self.use_cache
dependency_cache = {} if dependency_cache is None else dependency_cache
sub_dependent: Dependent = self.dependent
sub_dependent = self.dependent
call = cast(Callable[..., Any], sub_dependent.call)
# solve sub dependency with current cache

View File

@@ -114,7 +114,7 @@ def on(
rule: Optional[Union[Rule, T_RuleChecker]] = None,
permission: Optional[Union[Permission, T_PermissionChecker]] = None,
*,
handlers: Optional[list[Union[T_Handler, Dependent]]] = None,
handlers: Optional[list[Union[T_Handler, Dependent[Any]]]] = None,
temp: bool = False,
expire_time: Optional[Union[datetime, timedelta]] = None,
priority: int = 1,

View File

@@ -21,7 +21,7 @@ def on(
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
*,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -32,7 +32,7 @@ def on_metaevent(
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
*,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -43,7 +43,7 @@ def on_message(
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
*,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -54,7 +54,7 @@ def on_notice(
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
*,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -65,7 +65,7 @@ def on_request(
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
*,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -78,7 +78,7 @@ def on_startswith(
ignorecase: bool = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -91,7 +91,7 @@ def on_endswith(
ignorecase: bool = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -104,7 +104,7 @@ def on_fullmatch(
ignorecase: bool = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -116,7 +116,7 @@ def on_keyword(
rule: Rule | T_RuleChecker | None = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -130,7 +130,7 @@ def on_command(
force_whitespace: str | bool | None = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -144,7 +144,7 @@ def on_shell_command(
parser: ArgumentParser | None = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -157,7 +157,7 @@ def on_regex(
rule: Rule | T_RuleChecker | None = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -169,7 +169,7 @@ def on_type(
rule: Rule | T_RuleChecker | None = ...,
*,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -194,7 +194,7 @@ class CommandGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -209,7 +209,7 @@ class CommandGroup(_Group):
aliases: set[str | tuple[str, ...]] | None = ...,
force_whitespace: str | bool | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -224,7 +224,7 @@ class CommandGroup(_Group):
aliases: set[str | tuple[str, ...]] | None = ...,
parser: ArgumentParser | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -239,7 +239,7 @@ class MatcherGroup(_Group):
type: str = ...,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -252,7 +252,7 @@ class MatcherGroup(_Group):
type: str = ...,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -264,7 +264,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -276,7 +276,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -288,7 +288,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -300,7 +300,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -314,7 +314,7 @@ class MatcherGroup(_Group):
ignorecase: bool = ...,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -328,7 +328,7 @@ class MatcherGroup(_Group):
ignorecase: bool = ...,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -342,7 +342,7 @@ class MatcherGroup(_Group):
ignorecase: bool = ...,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -355,7 +355,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -370,7 +370,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -385,7 +385,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -399,7 +399,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,
@@ -412,7 +412,7 @@ class MatcherGroup(_Group):
*,
rule: Rule | T_RuleChecker | None = ...,
permission: Permission | T_PermissionChecker | None = ...,
handlers: list[T_Handler | Dependent] | None = ...,
handlers: list[T_Handler | Dependent[Any]] | None = ...,
temp: bool = ...,
expire_time: datetime | timedelta | None = ...,
priority: int = ...,

View File

@@ -13,7 +13,6 @@ FrontMatter:
import sys
import types
import warnings
import contextlib
import typing as t
import typing_extensions as t_ext
from typing import TYPE_CHECKING, TypeVar
@@ -86,9 +85,7 @@ def all_literal_values(type_: type[t.Any]) -> list[t.Any]:
def origin_is_annotated(origin: t.Optional[type[t.Any]]) -> bool:
"""判断是否是 Annotated 类型"""
with contextlib.suppress(TypeError):
return origin is not None and issubclass(origin, t_ext.Annotated)
return False
return origin is t_ext.Annotated
NONE_TYPES = {None, type(None), t.Literal[None], t_ext.Literal[None]}

View File

@@ -1,13 +1,14 @@
from typing import Any, Optional
from dataclasses import dataclass
from typing import Any, Optional, Annotated
import pytest
from pydantic import BaseModel
from pydantic import BaseModel, ValidationError
from nonebot.compat import (
DEFAULT_CONFIG,
Required,
FieldInfo,
TypeAdapter,
PydanticUndefined,
model_dump,
custom_validation,
@@ -31,6 +32,21 @@ async def test_field_info():
assert FieldInfo(test="test").extra["test"] == "test"
@pytest.mark.asyncio
async def test_type_adapter():
t = TypeAdapter(Annotated[int, FieldInfo(ge=1)])
assert t.validate_python(2) == 2
with pytest.raises(ValidationError):
t.validate_python(0)
assert t.validate_json("2") == 2
with pytest.raises(ValidationError):
t.validate_json("0")
@pytest.mark.asyncio
async def test_model_dump():
class TestModel(BaseModel):

View File

@@ -574,7 +574,7 @@ async def test_default(app: App):
async def test_priority():
from plugins.param.priority import complex_priority
dependent = Dependent.parse(
dependent = Dependent[None].parse(
call=complex_priority,
allow_types=[
DependParam,

View File

@@ -73,10 +73,12 @@ CUSTOM_CONFIG=config in dotenv
同时,设置环境变量:
```bash
# windows
set CUSTOM_CONFIG "config in environment variables"
# windows cmd
set CUSTOM_CONFIG 'config in environment variables'
# windows powershell
$Env:CUSTOM_CONFIG='config in environment variables'
# linux/macOS
export CUSTOM_CONFIG="config in environment variables"
export CUSTOM_CONFIG='config in environment variables'
```
那最终 NoneBot 所读取的内容为环境变量中的内容,即 `config in environment variables`。
@@ -295,8 +297,10 @@ DRIVER=~fastapi+~httpx+~websockets
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set DRIVER '~fastapi+~httpx+~websockets'
# windows powershell
$Env:DRIVER='~fastapi+~httpx+~websockets'
# linux/macOS
export DRIVER='~fastapi+~httpx+~websockets'
```
@@ -331,8 +335,10 @@ HOST=127.0.0.1
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set HOST '127.0.0.1'
# windows powershell
$Env:HOST='127.0.0.1'
# linux/macOS
export HOST='127.0.0.1'
```
@@ -367,8 +373,10 @@ PORT=8080
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set PORT '8080'
# windows powershell
$Env:PORT='8080'
# linux/macOS
export PORT='8080'
```
@@ -407,8 +415,10 @@ LOG_LEVEL=DEBUG
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set LOG_LEVEL 'DEBUG'
# windows powershell
$Env:LOG_LEVEL='DEBUG'
# linux/macOS
export LOG_LEVEL='DEBUG'
```
@@ -443,8 +453,10 @@ API_TIMEOUT=10.0
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set API_TIMEOUT '10.0'
# windows powershell
$Env:API_TIMEOUT='10.0'
# linux/macOS
export API_TIMEOUT='10.0'
```
@@ -479,8 +491,10 @@ SUPERUSERS=["123123123"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SUPERUSERS '["123123123"]'
# windows powershell
$Env:SUPERUSERS='["123123123"]'
# linux/macOS
export SUPERUSERS='["123123123"]'
```
@@ -515,8 +529,10 @@ NICKNAME=["bot"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set NICKNAME '["bot"]'
# windows powershell
$Env:NICKNAME='["bot"]'
# linux/macOS
export NICKNAME='["bot"]'
```
@@ -554,9 +570,12 @@ COMMAND_SEP=[".", " "]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set COMMAND_START '["/", ""]'
set COMMAND_SEP '[".", " "]'
# windows powershell
$Env:COMMAND_START='["/", ""]'
$Env:COMMAND_SEP='[".", " "]'
# linux/macOS
export COMMAND_START='["/", ""]'
export COMMAND_SEP='[".", " "]'
@@ -592,8 +611,10 @@ SESSION_EXPIRE_TIMEOUT=00:02:00
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SESSION_EXPIRE_TIMEOUT '00:02:00'
# windows powershell
$Env:SESSION_EXPIRE_TIMEOUT='00:02:00'
# linux/macOS
export SESSION_EXPIRE_TIMEOUT='00:02:00'
```

View File

@@ -31,17 +31,17 @@ require("nonebot_plugin_localstore")
import nonebot_plugin_localstore as store
# 获取插件缓存目录
cache_dir = store.get_cache_dir("plugin_name")
cache_dir = store.get_plugin_cache_dir()
# 获取插件缓存文件
cache_file = store.get_cache_file("plugin_name", "file_name")
cache_file = store.get_plugin_cache_file("file_name")
# 获取插件数据目录
data_dir = store.get_data_dir("plugin_name")
data_dir = store.get_plugin_data_dir()
# 获取插件数据文件
data_file = store.get_data_file("plugin_name", "file_name")
data_file = store.get_plugin_data_file("file_name")
# 获取插件配置目录
config_dir = store.get_config_dir("plugin_name")
config_dir = store.get_plugin_config_dir()
# 获取插件配置文件
config_file = store.get_config_file("plugin_name", "file_name")
config_file = store.get_plugin_config_file("file_name")
```
:::danger 警告
@@ -53,9 +53,61 @@ config_file = store.get_config_file("plugin_name", "file_name")
```python
from pathlib import Path
data_file = store.get_data_file("plugin_name", "file_name")
data_file = store.get_plugin_data_file("file_name")
# 写入文件内容
data_file.write_text("Hello World!")
# 读取文件内容
data = data_file.read_text()
```
:::note 提示
对于嵌套插件,子插件的存储目录将位于父插件存储目录下。
:::
## 配置项
### localstore_cache_dir
自定义缓存目录
默认值:
- macOS: `~/Library/Caches/<AppName>`
- Unix: `~/.cache/<AppName>` (XDG default)
- Windows: `C:\Users\<username>\AppData\Local\<AppName>\Cache`
```dotenv
LOCALSTORE_CACHE_DIR=/tmp/cache
```
### localstore_data_dir
自定义数据目录
默认值:
- macOS: `~/Library/Application Support/<AppName>`
- Unix: `~/.local/share/<AppName>` or in $XDG_DATA_HOME, if defined
- Win XP (not roaming): `C:\Documents and Settings\<username>\Application Data\<AppName>`
- Win 7 (not roaming): `C:\Users\<username>\AppData\Local\<AppName>`
```dotenv
LOCALSTORE_DATA_DIR=/tmp/data
```
### localstore_config_dir
自定义配置目录
默认值:
- macOS: same as user_data_dir
- Unix: `~/.config/<AppName>`
- Win XP (roaming): `C:\Documents and Settings\<username>\Local Settings\Application Data\<AppName>`
- Win 7 (roaming): `C:\Users\<username>\AppData\Roaming\<AppName>`
```dotenv
LOCALSTORE_CONFIG_DIR=/tmp/config
```

View File

@@ -5,6 +5,64 @@ toc_max_heading_level: 2
# 更新日志
## 最近更新
### 🚀 新功能
- Feature: 优化依赖注入在 pydantic v2 下的性能 [@yanyongyu](https://github.com/yanyongyu) ([#2870](https://github.com/nonebot/nonebot2/pull/2870))
- Feature: 添加遗漏的类型标注 [@yanyongyu](https://github.com/yanyongyu) ([#2856](https://github.com/nonebot/nonebot2/pull/2856))
### 🐛 Bug 修复
- Fix: 错误的类型标注和 annotated 处理 [@yanyongyu](https://github.com/yanyongyu) ([#2828](https://github.com/nonebot/nonebot2/pull/2828))
### 📝 文档
- Docs: 添加 Windows Powershell 设置环境变量方法 [@LeoQuote](https://github.com/LeoQuote) ([#2874](https://github.com/nonebot/nonebot2/pull/2874))
- Docs: 更新 localstore 插件文档 [@yanyongyu](https://github.com/yanyongyu) ([#2871](https://github.com/nonebot/nonebot2/pull/2871))
### 💫 杂项
- Plugin: 修改插件 system-command 信息 [@tkgs0](https://github.com/tkgs0) ([#2862](https://github.com/nonebot/nonebot2/pull/2862))
- Plugin: 修改 nonebot-plugin-fishing 插件作者 [@ALittleBot](https://github.com/ALittleBot) ([#2854](https://github.com/nonebot/nonebot2/pull/2854))
- Bot: 更新 Minecraft QQBot 信息 [@Lonely-Sails](https://github.com/Lonely-Sails) ([#2838](https://github.com/nonebot/nonebot2/pull/2838))
- Plugin: 移除 kanonbot 插件 [@SuperGuGuGu](https://github.com/SuperGuGuGu) ([#2819](https://github.com/nonebot/nonebot2/pull/2819))
- Plugin: 更新插件 sparkapi 信息 [@CCLMSY](https://github.com/CCLMSY) ([#2812](https://github.com/nonebot/nonebot2/pull/2812))
- Plugin: 修改插件 miragetank \& charpic 信息 [@1umine](https://github.com/1umine) ([#2807](https://github.com/nonebot/nonebot2/pull/2807))
### 🍻 插件发布
- Plugin: pokepoke_miss [@noneflow](https://github.com/noneflow) ([#2883](https://github.com/nonebot/nonebot2/pull/2883))
- Plugin: 聊天截图伪造 [@noneflow](https://github.com/noneflow) ([#2880](https://github.com/nonebot/nonebot2/pull/2880))
- Plugin: ba-tools [@noneflow](https://github.com/noneflow) ([#2867](https://github.com/nonebot/nonebot2/pull/2867))
- Plugin: 精华消息管理 [@noneflow](https://github.com/noneflow) ([#2873](https://github.com/nonebot/nonebot2/pull/2873))
- Plugin: B站收藏夹监视器 [@noneflow](https://github.com/noneflow) ([#2869](https://github.com/nonebot/nonebot2/pull/2869))
- Plugin: Alist [@noneflow](https://github.com/noneflow) ([#2865](https://github.com/nonebot/nonebot2/pull/2865))
- Plugin: 🦌管签到 [@noneflow](https://github.com/noneflow) ([#2859](https://github.com/nonebot/nonebot2/pull/2859))
- Plugin: 漂流瓶 [@noneflow](https://github.com/noneflow) ([#2861](https://github.com/nonebot/nonebot2/pull/2861))
- Plugin: 奇怪的小功能 [@noneflow](https://github.com/noneflow) ([#2851](https://github.com/nonebot/nonebot2/pull/2851))
- Plugin: SunoAI音乐生成 [@noneflow](https://github.com/noneflow) ([#2853](https://github.com/nonebot/nonebot2/pull/2853))
- Plugin: 谁是卷王 [@noneflow](https://github.com/noneflow) ([#2849](https://github.com/nonebot/nonebot2/pull/2849))
- Plugin: GPT-SoVITS 语音合成 [@noneflow](https://github.com/noneflow) ([#2847](https://github.com/nonebot/nonebot2/pull/2847))
- Plugin: 基于清影的AI视频生成 [@noneflow](https://github.com/noneflow) ([#2843](https://github.com/nonebot/nonebot2/pull/2843))
- Plugin: 命令行 [@noneflow](https://github.com/noneflow) ([#2840](https://github.com/nonebot/nonebot2/pull/2840))
- Plugin: exe_code [@noneflow](https://github.com/noneflow) ([#2835](https://github.com/nonebot/nonebot2/pull/2835))
- Plugin: nonebot-plugin-autopush [@noneflow](https://github.com/noneflow) ([#2833](https://github.com/nonebot/nonebot2/pull/2833))
- Plugin: vv_helper [@noneflow](https://github.com/noneflow) ([#2825](https://github.com/nonebot/nonebot2/pull/2825))
- Plugin: nonebot_plugin_game_torrent [@noneflow](https://github.com/noneflow) ([#2827](https://github.com/nonebot/nonebot2/pull/2827))
- Plugin: 每日油价 [@noneflow](https://github.com/noneflow) ([#2822](https://github.com/nonebot/nonebot2/pull/2822))
- Plugin: wordle [@noneflow](https://github.com/noneflow) ([#2818](https://github.com/nonebot/nonebot2/pull/2818))
- Plugin: 再润 [@noneflow](https://github.com/noneflow) ([#2816](https://github.com/nonebot/nonebot2/pull/2816))
- Plugin: 漫展/展览查询 [@noneflow](https://github.com/noneflow) ([#2811](https://github.com/nonebot/nonebot2/pull/2811))
- Plugin: 鸣潮wiki [@noneflow](https://github.com/noneflow) ([#2804](https://github.com/nonebot/nonebot2/pull/2804))
- Plugin: cloudfare R2 客服端 [@noneflow](https://github.com/noneflow) ([#2806](https://github.com/nonebot/nonebot2/pull/2806))
- Plugin: AnyMate小助手 [@noneflow](https://github.com/noneflow) ([#2761](https://github.com/nonebot/nonebot2/pull/2761))
### 🍻 机器人发布
- Bot: Minecraft_QQBot [@noneflow](https://github.com/noneflow) ([#2837](https://github.com/nonebot/nonebot2/pull/2837))
- Bot: 星辰 Bot [@noneflow](https://github.com/noneflow) ([#2824](https://github.com/nonebot/nonebot2/pull/2824))
## v2.3.2
### 🐛 Bug 修复

View File

@@ -73,10 +73,12 @@ CUSTOM_CONFIG=config in dotenv
同时,设置环境变量:
```bash
# windows
set CUSTOM_CONFIG "config in environment variables"
# windows cmd
set CUSTOM_CONFIG 'config in environment variables'
# windows powershell
$Env:CUSTOM_CONFIG='config in environment variables'
# linux/macOS
export CUSTOM_CONFIG="config in environment variables"
export CUSTOM_CONFIG='config in environment variables'
```
那最终 NoneBot 所读取的内容为环境变量中的内容,即 `config in environment variables`。
@@ -295,8 +297,10 @@ DRIVER=~fastapi+~httpx+~websockets
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set DRIVER '~fastapi+~httpx+~websockets'
# windows powershell
$Env:DRIVER='~fastapi+~httpx+~websockets'
# linux/macOS
export DRIVER='~fastapi+~httpx+~websockets'
```
@@ -331,8 +335,10 @@ HOST=127.0.0.1
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set HOST '127.0.0.1'
# windows powershell
$Env:HOST='127.0.0.1'
# linux/macOS
export HOST='127.0.0.1'
```
@@ -367,8 +373,10 @@ PORT=8080
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set PORT '8080'
# windows powershell
$Env:PORT='8080'
# linux/macOS
export PORT='8080'
```
@@ -407,8 +415,10 @@ LOG_LEVEL=DEBUG
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set LOG_LEVEL 'DEBUG'
# windows powershell
$Env:LOG_LEVEL='DEBUG'
# linux/macOS
export LOG_LEVEL='DEBUG'
```
@@ -443,8 +453,10 @@ API_TIMEOUT=10.0
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set API_TIMEOUT '10.0'
# windows powershell
$Env:API_TIMEOUT='10.0'
# linux/macOS
export API_TIMEOUT='10.0'
```
@@ -479,8 +491,10 @@ SUPERUSERS=["123123123"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SUPERUSERS '["123123123"]'
# windows powershell
$Env:SUPERUSERS='["123123123"]'
# linux/macOS
export SUPERUSERS='["123123123"]'
```
@@ -515,8 +529,10 @@ NICKNAME=["bot"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set NICKNAME '["bot"]'
# windows powershell
$Env:NICKNAME='["bot"]'
# linux/macOS
export NICKNAME='["bot"]'
```
@@ -554,9 +570,12 @@ COMMAND_SEP=[".", " "]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set COMMAND_START '["/", ""]'
set COMMAND_SEP '[".", " "]'
# windows powershell
$Env:COMMAND_START='["/", ""]'
$Env:COMMAND_SEP='[".", " "]'
# linux/macOS
export COMMAND_START='["/", ""]'
export COMMAND_SEP='[".", " "]'
@@ -592,8 +611,10 @@ SESSION_EXPIRE_TIMEOUT=00:02:00
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SESSION_EXPIRE_TIMEOUT '00:02:00'
# windows powershell
$Env:SESSION_EXPIRE_TIMEOUT='00:02:00'
# linux/macOS
export SESSION_EXPIRE_TIMEOUT='00:02:00'
```

View File

@@ -73,10 +73,12 @@ CUSTOM_CONFIG=config in dotenv
同时,设置环境变量:
```bash
# windows
set CUSTOM_CONFIG "config in environment variables"
# windows cmd
set CUSTOM_CONFIG 'config in environment variables'
# windows powershell
$Env:CUSTOM_CONFIG='config in environment variables'
# linux/macOS
export CUSTOM_CONFIG="config in environment variables"
export CUSTOM_CONFIG='config in environment variables'
```
那最终 NoneBot 所读取的内容为环境变量中的内容,即 `config in environment variables`。
@@ -295,8 +297,10 @@ DRIVER=~fastapi+~httpx+~websockets
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set DRIVER '~fastapi+~httpx+~websockets'
# windows powershell
$Env:DRIVER='~fastapi+~httpx+~websockets'
# linux/macOS
export DRIVER='~fastapi+~httpx+~websockets'
```
@@ -331,8 +335,10 @@ HOST=127.0.0.1
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set HOST '127.0.0.1'
# windows powershell
$Env:HOST='127.0.0.1'
# linux/macOS
export HOST='127.0.0.1'
```
@@ -367,8 +373,10 @@ PORT=8080
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set PORT '8080'
# windows powershell
$Env:PORT='8080'
# linux/macOS
export PORT='8080'
```
@@ -407,8 +415,10 @@ LOG_LEVEL=DEBUG
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set LOG_LEVEL 'DEBUG'
# windows powershell
$Env:LOG_LEVEL='DEBUG'
# linux/macOS
export LOG_LEVEL='DEBUG'
```
@@ -443,8 +453,10 @@ API_TIMEOUT=10.0
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set API_TIMEOUT '10.0'
# windows powershell
$Env:API_TIMEOUT='10.0'
# linux/macOS
export API_TIMEOUT='10.0'
```
@@ -479,8 +491,10 @@ SUPERUSERS=["123123123"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SUPERUSERS '["123123123"]'
# windows powershell
$Env:SUPERUSERS='["123123123"]'
# linux/macOS
export SUPERUSERS='["123123123"]'
```
@@ -515,8 +529,10 @@ NICKNAME=["bot"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set NICKNAME '["bot"]'
# windows powershell
$Env:NICKNAME='["bot"]'
# linux/macOS
export NICKNAME='["bot"]'
```
@@ -554,9 +570,12 @@ COMMAND_SEP=[".", " "]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set COMMAND_START '["/", ""]'
set COMMAND_SEP '[".", " "]'
# windows powershell
$Env:COMMAND_START='["/", ""]'
$Env:COMMAND_SEP='[".", " "]'
# linux/macOS
export COMMAND_START='["/", ""]'
export COMMAND_SEP='[".", " "]'
@@ -592,8 +611,10 @@ SESSION_EXPIRE_TIMEOUT=00:02:00
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SESSION_EXPIRE_TIMEOUT '00:02:00'
# windows powershell
$Env:SESSION_EXPIRE_TIMEOUT='00:02:00'
# linux/macOS
export SESSION_EXPIRE_TIMEOUT='00:02:00'
```

View File

@@ -73,10 +73,12 @@ CUSTOM_CONFIG=config in dotenv
同时,设置环境变量:
```bash
# windows
set CUSTOM_CONFIG "config in environment variables"
# windows cmd
set CUSTOM_CONFIG 'config in environment variables'
# windows powershell
$Env:CUSTOM_CONFIG='config in environment variables'
# linux/macOS
export CUSTOM_CONFIG="config in environment variables"
export CUSTOM_CONFIG='config in environment variables'
```
那最终 NoneBot 所读取的内容为环境变量中的内容,即 `config in environment variables`。
@@ -295,8 +297,10 @@ DRIVER=~fastapi+~httpx+~websockets
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set DRIVER '~fastapi+~httpx+~websockets'
# windows powershell
$Env:DRIVER='~fastapi+~httpx+~websockets'
# linux/macOS
export DRIVER='~fastapi+~httpx+~websockets'
```
@@ -331,8 +335,10 @@ HOST=127.0.0.1
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set HOST '127.0.0.1'
# windows powershell
$Env:HOST='127.0.0.1'
# linux/macOS
export HOST='127.0.0.1'
```
@@ -367,8 +373,10 @@ PORT=8080
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set PORT '8080'
# windows powershell
$Env:PORT='8080'
# linux/macOS
export PORT='8080'
```
@@ -407,8 +415,10 @@ LOG_LEVEL=DEBUG
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set LOG_LEVEL 'DEBUG'
# windows powershell
$Env:LOG_LEVEL='DEBUG'
# linux/macOS
export LOG_LEVEL='DEBUG'
```
@@ -443,8 +453,10 @@ API_TIMEOUT=10.0
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set API_TIMEOUT '10.0'
# windows powershell
$Env:API_TIMEOUT='10.0'
# linux/macOS
export API_TIMEOUT='10.0'
```
@@ -479,8 +491,10 @@ SUPERUSERS=["123123123"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SUPERUSERS '["123123123"]'
# windows powershell
$Env:SUPERUSERS='["123123123"]'
# linux/macOS
export SUPERUSERS='["123123123"]'
```
@@ -515,8 +529,10 @@ NICKNAME=["bot"]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set NICKNAME '["bot"]'
# windows powershell
$Env:NICKNAME='["bot"]'
# linux/macOS
export NICKNAME='["bot"]'
```
@@ -554,9 +570,12 @@ COMMAND_SEP=[".", " "]
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set COMMAND_START '["/", ""]'
set COMMAND_SEP '[".", " "]'
# windows powershell
$Env:COMMAND_START='["/", ""]'
$Env:COMMAND_SEP='[".", " "]'
# linux/macOS
export COMMAND_START='["/", ""]'
export COMMAND_SEP='[".", " "]'
@@ -592,8 +611,10 @@ SESSION_EXPIRE_TIMEOUT=00:02:00
<TabItem value="env" label="系统环境变量">
```bash
# windows
# windows cmd
set SESSION_EXPIRE_TIMEOUT '00:02:00'
# windows powershell
$Env:SESSION_EXPIRE_TIMEOUT='00:02:00'
# linux/macOS
export SESSION_EXPIRE_TIMEOUT='00:02:00'
```

View File

@@ -1512,7 +1512,7 @@
sitemap "^7.1.1"
tslib "^2.4.0"
"@docusaurus/react-loadable@5.5.2", "react-loadable@npm:@docusaurus/react-loadable@5.5.2":
"@docusaurus/react-loadable@5.5.2":
version "5.5.2"
resolved "https://registry.npmjs.org/@docusaurus/react-loadable/-/react-loadable-5.5.2.tgz#81aae0db81ecafbdaee3651f12804580868fa6ce"
integrity sha512-A3dYjdBGuy0IGT+wyLIGIKLRE+sAk1iNk0f1HjNDysO7u8lhL4N3VEm+FAubmJbAztn94F7MxBTPmnixbiyFdQ==
@@ -7620,9 +7620,9 @@ pure-color@^1.2.0:
integrity sha512-QFADYnsVoBMw1srW7OVKEYjG+MbIa49s54w1MA1EDY6r2r/sTcKKYqRX1f4GYvnXP7eN/Pe9HFcX+hwzmrXRHA==
pyright@^1.1.317:
version "1.1.352"
resolved "https://registry.npmjs.org/pyright/-/pyright-1.1.352.tgz#2feb37438bc79ddf2bc1fdcc139f4ba088719f14"
integrity sha512-X7fuuB24n3RIVCEPovrAadYJjxeB5RccArug+/oLwQnsHbSaDUQVHHkF/PJHkKpaIPX/RboG+EW8uCNUp1RnwQ==
version "1.1.372"
resolved "https://registry.npmjs.org/pyright/-/pyright-1.1.372.tgz#4ac7b6ca189b58629ef26445f98c6685849dda5a"
integrity sha512-S0XYmTQWK+ha9FTIWviNk91UnbD569wPUCNEltSqtHeTJhbHj5z3LkOKiqXAOvn72BBfylcgpQqyQHsocmQtiQ==
optionalDependencies:
fsevents "~2.3.3"
@@ -7805,6 +7805,14 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1:
dependencies:
"@babel/runtime" "^7.10.3"
"react-loadable@npm:@docusaurus/react-loadable@5.5.2":
version "5.5.2"
resolved "https://registry.npmjs.org/@docusaurus/react-loadable/-/react-loadable-5.5.2.tgz#81aae0db81ecafbdaee3651f12804580868fa6ce"
integrity sha512-A3dYjdBGuy0IGT+wyLIGIKLRE+sAk1iNk0f1HjNDysO7u8lhL4N3VEm+FAubmJbAztn94F7MxBTPmnixbiyFdQ==
dependencies:
"@types/react" "*"
prop-types "^15.6.2"
react-router-config@^5.1.1:
version "5.1.1"
resolved "https://registry.npmjs.org/react-router-config/-/react-router-config-5.1.1.tgz#0f4263d1a80c6b2dc7b9c1902c9526478194a988"