From 152661141390fe41afeec12216b1874e64471829 Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Sun, 4 Aug 2024 19:31:21 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=B7=BB=E5=8A=A0shortcut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/builtin_plugins/admin/admin_help.py | 1 - .../chat_history/chat_message_handle.py | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/zhenxun/builtin_plugins/admin/admin_help.py b/zhenxun/builtin_plugins/admin/admin_help.py index 0b56da42..bdf48929 100644 --- a/zhenxun/builtin_plugins/admin/admin_help.py +++ b/zhenxun/builtin_plugins/admin/admin_help.py @@ -5,7 +5,6 @@ from nonebot_plugin_alconna.matcher import AlconnaMatcher from nonebot_plugin_saa import Image, Text from nonebot_plugin_session import EventSession -from zhenxun.configs.config import Config from zhenxun.configs.path_config import IMAGE_PATH from zhenxun.configs.utils import PluginExtraData from zhenxun.models.plugin_info import PluginInfo diff --git a/zhenxun/builtin_plugins/chat_history/chat_message_handle.py b/zhenxun/builtin_plugins/chat_history/chat_message_handle.py index 6e2cc8c9..c23d7ca9 100644 --- a/zhenxun/builtin_plugins/chat_history/chat_message_handle.py +++ b/zhenxun/builtin_plugins/chat_history/chat_message_handle.py @@ -1,11 +1,9 @@ from datetime import datetime, timedelta import pytz -from nonebot.adapters import Bot from nonebot.plugin import PluginMetadata from nonebot_plugin_alconna import ( Alconna, - AlconnaMatch, Args, Arparma, Match, @@ -32,11 +30,14 @@ __plugin_meta__ = PluginMetadata( 消息排行 ?[type [日,周,月,年]] ?[--des] 快捷: - [日,周,月,年]消息排行 + [日,周,月,年]消息排行 ?[数量] 示例: - 消息排行 : 所有记录排行 - 日消息排行 : 今日记录排行 + 消息排行 : 所有记录排行 + 日消息排行 : 今日记录排行 + 周消息排行 : 今日记录排行 + 月消息排行 : 今日记录排行 + 年消息排行 : 今日记录排行 消息排行 周 --des : 逆序周记录排行 """.strip(), extra=PluginExtraData( @@ -60,16 +61,15 @@ _matcher = on_alconna( ) _matcher.shortcut( - r"(?P.+)?消息排行", + r"(?P['日', '周', '月', '年'])?消息(排行|统计)\s?(?P\d+)?", command="消息排行", - arguments=["{type}"], + arguments=["{type}", "{cnt}"], prefix=True, ) @_matcher.handle() async def _( - bot: Bot, session: EventSession, arparma: Arparma, type: Match[str], @@ -111,7 +111,7 @@ async def _( ).replace(microsecond=0) else: date_scope = time_now.replace(microsecond=0) - date_str = f"{date_scope} - 至今" + date_str = f"{str(date_scope).split('+')[0]} - 至今" else: date_str = f"{date_scope[0].replace(microsecond=0)} - {date_scope[1].replace(microsecond=0)}" A = await ImageTemplate.table_page(