From 3cc5a4447c99669fe26bfc0173a172af1b9504cc Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Wed, 9 Jul 2025 09:53:33 +0800 Subject: [PATCH 1/2] fix: support search with space Signed-off-by: Frost Ming --- handlers/summary/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handlers/summary/__init__.py b/handlers/summary/__init__.py index 1b5952c..7e96b37 100644 --- a/handlers/summary/__init__.py +++ b/handlers/summary/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging from datetime import datetime, timezone from functools import partial +import shlex import telegramify_markdown from telebot import TeleBot @@ -96,7 +97,7 @@ def stats_command(message: Message, bot: TeleBot): @non_llm_handler def search_command(message: Message, bot: TeleBot): """搜索群组消息(示例:/search 关键词 [N])""" - text_parts = message.text.split(maxsplit=2) + text_parts = shlex.split(message.text) if len(text_parts) < 2: bot.reply_to(message, "请提供要搜索的关键词。") return @@ -115,7 +116,7 @@ def search_command(message: Message, bot: TeleBot): items = [] for msg in messages: link = f"https://t.me/c/{chat_id}/{msg.message_id}" - items.append(f"{link}\n```\n{msg.content}\n```") + items.append(f"{link}\n```\n{msg.user_name}: {msg.content}\n```") message_text = telegramify_markdown.markdownify("\n".join(items)) bot.reply_to( message, From 124b2f0d9bb93ab6a30bc1c268b2ec2510879e0e Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Wed, 9 Jul 2025 12:56:05 +0800 Subject: [PATCH 2/2] fix: compare timestamp Signed-off-by: Frost Ming --- handlers/summary/messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/summary/messages.py b/handlers/summary/messages.py index 212c125..a39a842 100644 --- a/handlers/summary/messages.py +++ b/handlers/summary/messages.py @@ -92,7 +92,7 @@ class MessageStore: WHERE chat_id = ? AND timestamp >= ? ORDER BY timestamp ASC; """, - (chat_id, since.isoformat()), + (chat_id, since.astimezone(timezone.utc).isoformat()), ) rows = cursor.fetchall() return [