diff --git a/pkg/qqbot/banlist.py b/pkg/qqbot/banlist.py index 0296c85b..2c7dcb12 100644 --- a/pkg/qqbot/banlist.py +++ b/pkg/qqbot/banlist.py @@ -1,30 +1,34 @@ import pkg.utils.context -def is_banned(launcher_type: str, launcher_id: int) -> bool: +def is_banned(launcher_type: str, launcher_id: int, sender_id: int) -> bool: if not pkg.utils.context.get_qqbot_manager().enable_banlist: return False result = False if launcher_type == 'group': - for group_rule in pkg.utils.context.get_qqbot_manager().ban_group: - if type(group_rule) == int: - if group_rule == launcher_id: # 此群群号被禁用 - result = True - elif type(group_rule) == str: - if group_rule.startswith('!'): - # 截取!后面的字符串作为表达式,判断是否匹配 - reg_str = group_rule[1:] - import re - if re.match(reg_str, str(launcher_id)): # 被豁免,最高级别 - result = False - break - else: - # 判断是否匹配regexp - import re - if re.match(group_rule, str(launcher_id)): # 此群群号被禁用 + # 检查是否显式声明发起人QQ要被person忽略 + if sender_id in pkg.utils.context.get_qqbot_manager().ban_person: + result = True + else: + for group_rule in pkg.utils.context.get_qqbot_manager().ban_group: + if type(group_rule) == int: + if group_rule == launcher_id: # 此群群号被禁用 result = True + elif type(group_rule) == str: + if group_rule.startswith('!'): + # 截取!后面的字符串作为表达式,判断是否匹配 + reg_str = group_rule[1:] + import re + if re.match(reg_str, str(launcher_id)): # 被豁免,最高级别 + result = False + break + else: + # 判断是否匹配regexp + import re + if re.match(group_rule, str(launcher_id)): # 此群群号被禁用 + result = True else: # ban_person, 与群规则相同 diff --git a/pkg/qqbot/process.py b/pkg/qqbot/process.py index 0f34ed1b..c5b55866 100644 --- a/pkg/qqbot/process.py +++ b/pkg/qqbot/process.py @@ -49,7 +49,7 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes session_name = "{}_{}".format(launcher_type, launcher_id) # 检查发送方是否被禁用 - if banlist.is_banned(launcher_type, launcher_id): + if banlist.is_banned(launcher_type, launcher_id, sender_id): logging.info("根据禁用列表忽略{}_{}的消息".format(launcher_type, launcher_id)) return []