From 8be864ecd7c045a0b515c5b86cbd56e2e3821c80 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Sat, 19 Oct 2024 00:25:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E8=A1=A5=E4=B8=8A=20require?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_watch/__init__.py | 18 ++++-------------- nonebot_plugin_watch/matcher.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 nonebot_plugin_watch/matcher.py diff --git a/nonebot_plugin_watch/__init__.py b/nonebot_plugin_watch/__init__.py index 3a311da..edf6036 100644 --- a/nonebot_plugin_watch/__init__.py +++ b/nonebot_plugin_watch/__init__.py @@ -1,16 +1,6 @@ -from nonebot import on_message -from nonebot_plugin_alconna.uniseg import UniMsg -from nonebot_plugin_uninfo import Uninfo # type: ignore[import-untyped] -from plyer import notification # type: ignore[import-untyped] +from nonebot import require -from .config import config +require("nonebot_plugin_alconna") +require("nonebot_plugin_uninfo") - -@on_message().handle() -async def _(session: Uninfo, msg: UniMsg): - if session.user.id in config.watch_ids: - notification.notify( # type: ignore - title=f"{session.user.nick or session.user.name or session.user.id} 发言", - message=repr(msg), - timeout=10, - ) +from . import matcher # noqa: E402, F401 diff --git a/nonebot_plugin_watch/matcher.py b/nonebot_plugin_watch/matcher.py new file mode 100644 index 0000000..3a311da --- /dev/null +++ b/nonebot_plugin_watch/matcher.py @@ -0,0 +1,16 @@ +from nonebot import on_message +from nonebot_plugin_alconna.uniseg import UniMsg +from nonebot_plugin_uninfo import Uninfo # type: ignore[import-untyped] +from plyer import notification # type: ignore[import-untyped] + +from .config import config + + +@on_message().handle() +async def _(session: Uninfo, msg: UniMsg): + if session.user.id in config.watch_ids: + notification.notify( # type: ignore + title=f"{session.user.nick or session.user.name or session.user.id} 发言", + message=repr(msg), + timeout=10, + )