⬆️ auto update by pre-commit hooks (#4181)
Release Drafter / release (push) Skipped
Release Drafter / update-release-draft (push) Failing after 38s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 43s
Ruff Lint / Ruff Lint (push) Successful in 57s
Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 1m1s
Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 1m4s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.13) (push) Failing after 1m4s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 1m5s
Site Deploy / publish (push) Failing after 1m8s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.13) (push) Failing after 1m19s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 1m26s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 1m29s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 1m31s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 1m33s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.11) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.12) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.13) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.10) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.11) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.12) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.13) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.10) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.11) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.12) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.13) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.10) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.11) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.12) (push) Canceled after 0s
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.13) (push) Canceled after 0s

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot]
2026-09-11 22:03:57 +08:00
committed by GitHub
co-authored by pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
parent 9b4772ff8f
commit 206d31a61d
86 changed files with 819 additions and 271 deletions
@@ -76,7 +76,7 @@ logger.add(
level=0,
diagnose=True,
format="<g>{time:MM-DD HH:mm:ss}</g> [<lvl>{level}</lvl>] <c><u>{name}</u></c> | {message}",
filter=default_filter
filter=default_filter,
)
```
@@ -21,6 +21,7 @@ options:
```python {4} title=weather/__init__.py
from nonebot.adapters.console import MessageEvent
@weather.got("location", prompt="请输入地名")
async def got_location(event: MessageEvent, location: str = ArgPlainText()):
await weather.finish(f"{event.time.strftime('%Y-%m-%d')} {location} 的天气是...")
@@ -39,10 +40,12 @@ async def got_location(event: MessageEvent, location: str = ArgPlainText()):
```python {4,8}
from nonebot.adapters.onebot.v11 import PrivateMessageEvent, GroupMessageEvent
@matcher.handle()
async def handle_private(event: PrivateMessageEvent):
await matcher.finish("私聊消息")
@matcher.handle()
async def handle_group(event: GroupMessageEvent):
await matcher.finish("群聊消息")
@@ -54,10 +57,12 @@ async def handle_group(event: GroupMessageEvent):
from nonebot.adapters.console import Bot as ConsoleBot
from nonebot.adapters.onebot.v11 import Bot as OneBot
@matcher.handle()
async def handle_console(bot: ConsoleBot):
await bot.bell()
@matcher.handle()
async def handle_onebot(bot: OneBot):
await bot.send_group_message(group_id=123123, message="OneBot")
@@ -27,9 +27,11 @@ from .config import Config
plugin_config = get_plugin_config(Config)
async def is_enable() -> bool:
return plugin_config.weather_plugin_enabled
weather = on_command("天气", rule=is_enable)
```
@@ -43,12 +45,15 @@ weather = on_command("天气", rule=is_enable)
from nonebot.rule import Rule
from nonebot.adapters import Event
async def is_enable() -> bool:
return plugin_config.weather_plugin_enabled
async def is_blacklisted(event: Event) -> bool:
return event.get_user_id() not in BLACKLIST
rule = Rule(is_enable, is_blacklisted)
weather = on_command("天气", rule=rule)
@@ -66,9 +71,11 @@ from .config import Config
plugin_config = get_plugin_config(Config)
async def is_enable() -> bool:
return plugin_config.weather_plugin_enabled
weather = on_command(
"天气",
rule=to_me() & is_enable,
@@ -17,6 +17,7 @@ NoneBot 中的会话状态是一个字典,可以通过类型 `T_State` 来获
```python
from nonebot.typing import T_State
@matcher.got("key", prompt="请输入密码")
async def _(state: T_State, key: str = ArgPlainText()):
if key != "some password":
@@ -34,10 +35,12 @@ async def _(state: T_State, key: str = ArgPlainText()):
```python
from nonebot.typing import T_State
@matcher.handle()
async def _(state: T_State):
state["key"] = "value"
@matcher.handle()
async def _(state: T_State):
await matcher.finish(state["key"])
@@ -49,10 +52,12 @@ async def _(state: T_State):
from nonebot.typing import T_State
from nonebot.adapters import MessageTemplate
@matcher.handle()
async def _(state: T_State):
state["username"] = "user"
@matcher.got("password", prompt=MessageTemplate("请输入 {username} 的密码"))
async def _():
await matcher.finish(MessageTemplate("密码为 {password}"))