📝 Docs: 升级新版 NonePress 主题 (#2375)

This commit is contained in:
Ju4tCode
2023-09-27 16:00:26 +08:00
committed by GitHub
parent 7754f6da1d
commit 842c6ff4c6
234 changed files with 8759 additions and 5887 deletions

View File

@ -180,7 +180,7 @@ docker compose build
将以下文件添加至**项目目录**下的 `.github/workflows/` 目录下,并将文件中高亮行中的仓库名称替换为你的仓库名称:
```yaml title=.github/workflows/build.yml {34}
```yaml title=.github/workflows/build.yml
name: Docker Hub Release
on:
@ -213,6 +213,7 @@ jobs:
id: metadata
with:
images: |
# highlight-next-line
{organization}/{repository}
tags: |
type=semver,pattern={{version}}

View File

@ -27,7 +27,7 @@ nb plugin install nonebot-plugin-sentry
### 配置插件
:::warning 注意
:::caution 注意
错误跟踪通常在生产环境中使用,因此开发环境中 `sentry_dsn` 留空即会停用插件。
:::

View File

@ -58,7 +58,7 @@ scheduler.add_job(
)
```
:::warning 注意
:::caution 注意
由于 APScheduler 的定时任务并不是**由事件响应器所触发的事件**,因此其任务函数无法同[事件处理函数](../tutorial/handler.mdx#事件处理函数)一样通过[依赖注入](../tutorial/event-data.mdx#认识依赖注入)获取上下文信息,也无法通过事件响应器对象的方法进行任何操作,因此我们需要使用[调用平台 API](../appendices/api-calling.mdx#调用平台-api)的方式来获取信息或收发消息。
相对于事件处理依赖而言,编写定时任务更像是编写普通的函数,需要我们自行获取信息以及发送信息,请**不要**将事件处理依赖的特殊语法用于定时任务!

View File

@ -189,7 +189,7 @@ async def _(bot: Bot):
然后我们对该插件进行测试:
```python {19,20,23,24} title=tests/test_example.py
```python title=tests/test_example.py
from datetime import datetime
import pytest
@ -210,12 +210,16 @@ async def test_example(app: App):
from awesome_bot.plugins.example import foo
async with app.test_matcher(foo) as ctx:
# highlight-start
adapter = nonebot.get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
# highlight-end
event = make_event("/foo")
ctx.receive_event(bot, event)
# highlight-start
ctx.should_call_send(event, "message", result=None, bot=bot)
ctx.should_call_api("bell", {}, result=None, adapter=adapter)
# highlight-end
```
请注意,对于在依赖注入中使用了非基类对象的情况,我们需要在 `create_bot` 方法中指定 `base` 和 `adapter` 参数,确保不会因为重载功能而出现非预期情况。