mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 05:31:52 +00:00
fix: localize group analysis permission response
This commit is contained in:
@@ -235,6 +235,7 @@ _✨ 一个基于 AstrBot 的智能群聊分析插件,支持 **OneBot** (NapCa
|
||||
/phantichnhom [số ngày]
|
||||
```
|
||||
- Phân tích hoạt động trò chuyện gần đây của nhóm.
|
||||
- Chỉ quản trị viên đã được cấp quyền trong AstrBot mới có thể sử dụng.
|
||||
- Số ngày là tùy chọn, mặc định là 1 ngày.
|
||||
- Ví dụ: `/phantichnhom 3` phân tích 3 ngày gần nhất.
|
||||
|
||||
|
||||
@@ -490,7 +490,6 @@ class GroupDailyAnalysis(Star):
|
||||
pass
|
||||
|
||||
@filter.command("phantichnhom", alias={"group_analysis"})
|
||||
@filter.permission_type(PermissionType.ADMIN)
|
||||
async def analyze_group_daily(
|
||||
self, event: AstrMessageEvent, days: int | None = None
|
||||
):
|
||||
@@ -509,6 +508,17 @@ class GroupDailyAnalysis(Star):
|
||||
# Chặn cả LLM mặc định lẫn các handler tiếp theo xử lý lại slash command.
|
||||
event.should_call_llm(True)
|
||||
event.stop_event()
|
||||
|
||||
# Tự kiểm tra quyền để tránh thông báo mặc định bằng tiếng Trung của
|
||||
# AstrBot được gửi trước khi handler có cơ hội xử lý sự kiện.
|
||||
if not event.is_admin():
|
||||
sender_id = event.get_sender_id()
|
||||
yield event.plain_result(
|
||||
f"❌ Bạn (ID: {sender_id}) không có quyền sử dụng lệnh này. "
|
||||
"Hãy dùng /sid để lấy ID và nhờ quản trị viên thêm quyền."
|
||||
)
|
||||
return
|
||||
|
||||
group_id = self._get_group_id_from_event(event)
|
||||
platform_id = self._get_platform_id_from_event(event)
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: astrbot_plugin_qq_group_daily_analysis # Mã định danh duy nhất của plugin.
|
||||
display_name: Plugin tổng hợp và phân tích nhóm # Tên hiển thị của plugin.
|
||||
desc: "Plugin tổng hợp và phân tích hoạt động nhóm hằng ngày - hỗ trợ OneBot (NapCat, LLOneBot, Snowluma), bot QQ chính thức, Telegram và Discord; tạo báo cáo phân tích trò chuyện nhóm trực quan, hỗ trợ phân tích chủ đề, chân dung thành viên và trích dẫn nổi bật." # Mô tả ngắn của plugin.
|
||||
version: v4.11.3 # Phiên bản plugin, theo định dạng v1.1.1 hoặc v1.1.
|
||||
version: v4.11.4 # Phiên bản plugin, theo định dạng v1.1.1 hoặc v1.1.
|
||||
author: SXP-Simon # Tác giả.
|
||||
astrbot_version: ">=4.16.0"
|
||||
support_platforms:
|
||||
|
||||
@@ -224,12 +224,20 @@ def test_report_boundary_removes_chinese_semantics_but_keeps_identity():
|
||||
def test_group_analysis_command_stops_event_propagation():
|
||||
main_path = Path(__file__).resolve().parents[1] / "main.py"
|
||||
source = main_path.read_text(encoding="utf-8")
|
||||
decorator_start = source.index('@filter.command("phantichnhom"')
|
||||
command_start = source.index("async def analyze_group_daily(")
|
||||
command_end = source.index("async def _send_analysis_report(", command_start)
|
||||
decorator_source = source[decorator_start:command_start]
|
||||
command_source = source[command_start:command_end]
|
||||
|
||||
assert "permission_type" not in decorator_source
|
||||
assert "event.should_call_llm(True)" in command_source
|
||||
assert "event.stop_event()" in command_source
|
||||
assert "if not event.is_admin():" in command_source
|
||||
assert "không có quyền sử dụng lệnh này" in command_source
|
||||
assert command_source.index("event.stop_event()") < command_source.index(
|
||||
"execute_daily_analysis"
|
||||
)
|
||||
assert command_source.index("if not event.is_admin():") < command_source.index(
|
||||
"execute_daily_analysis"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user