Support group filter
This commit is contained in:
parent
f2595110a9
commit
a99269250e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user