fix: 无法根据ban_person忽略群内指定人消息 (#211)

This commit is contained in:
Rock Chin
2023-03-05 10:33:16 +08:00
parent 56e906c83f
commit a610a9d3d3
2 changed files with 22 additions and 18 deletions
+5 -1
View File
@@ -1,13 +1,17 @@
import pkg.utils.context 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: if not pkg.utils.context.get_qqbot_manager().enable_banlist:
return False return False
result = False result = False
if launcher_type == 'group': if launcher_type == 'group':
# 检查是否显式声明发起人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: for group_rule in pkg.utils.context.get_qqbot_manager().ban_group:
if type(group_rule) == int: if type(group_rule) == int:
if group_rule == launcher_id: # 此群群号被禁用 if group_rule == launcher_id: # 此群群号被禁用
+1 -1
View File
@@ -49,7 +49,7 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes
session_name = "{}_{}".format(launcher_type, launcher_id) 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)) logging.info("根据禁用列表忽略{}_{}的消息".format(launcher_type, launcher_id))
return [] return []