From a99269250e2b9b5f1dd6493743c862fa3d9acce2 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 7 Mar 2022 22:22:35 +0800 Subject: [PATCH] Support group filter --- efb_qq_plugin_go_cqhttp/GoCQHttp.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/efb_qq_plugin_go_cqhttp/GoCQHttp.py b/efb_qq_plugin_go_cqhttp/GoCQHttp.py index 71d657a..5737a3f 100644 --- a/efb_qq_plugin_go_cqhttp/GoCQHttp.py +++ b/efb_qq_plugin_go_cqhttp/GoCQHttp.py @@ -51,6 +51,8 @@ from .Utils import ( qq_emoji_list, ) +all_group_list = [] + class GoCQHttp(BaseClient): client_name: str = "GoCQHttp Client" @@ -210,6 +212,11 @@ class GoCQHttp(BaseClient): chat: PrivateChat = self.chat_manager.build_efb_chat_as_private(context) else: chat = self.chat_manager.build_efb_chat_as_group(context) + is_discuss = False if context['message_type'] == 'group' else True + chat_uid = context['discuss_id'] if is_discuss else context['group_id'] + if len(all_group_list) > 0 and chat_uid not in all_group_list: + print(f"Filter 1 msg from {chat.uid} {chat.name}.") + return if "anonymous" not in context or context["anonymous"] is None: if context["message_type"] == "group": @@ -260,6 +267,9 @@ class GoCQHttp(BaseClient): @self.coolq_bot.on_notice("group_increase") def handle_group_increase_msg(context): + if len(all_group_list) > 0 and context["group_id"] not in all_group_list: + print(f"Filter 1 group_increase from {context['group_id']}.") + return context["event_description"] = self._("\u2139 Group Member Increase Event") if (context["sub_type"]) == "invite": text = self._("{nickname}({context[user_id]}) joined the group({group_name}) via invitation") @@ -281,6 +291,9 @@ class GoCQHttp(BaseClient): @self.coolq_bot.on_notice("group_decrease") def handle_group_decrease_msg(context): + if len(all_group_list) > 0 and context["group_id"] not in all_group_list: + print(f"Filter 1 group_decrease from {context['group_id']}.") + return context["event_description"] = self._("\u2139 Group Member Decrease Event") original_group = self.get_group_info(context["group_id"], False) group_name = context["group_id"] @@ -320,6 +333,9 @@ class GoCQHttp(BaseClient): @self.coolq_bot.on_notice("group_upload") def handle_group_file_upload_msg(context): + if len(all_group_list) > 0 and context["group_id"] not in all_group_list: + print(f"Filter 1 file from {context['group_id']}.") + return context["event_description"] = self._("\u2139 Group File Upload Event") context["uid_prefix"] = "group_upload" original_group = self.get_group_info(context["group_id"], False)