fix: make bot identity platform-aware
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import json
|
||||
import traceback
|
||||
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import and_, func, not_, or_
|
||||
from sqlmodel import col, select
|
||||
|
||||
from src.common.database.database import get_db_session
|
||||
from src.common.database.database_model import Messages
|
||||
from src.chat.message_receive.message import SessionMessage
|
||||
from src.common.logger import get_logger
|
||||
from src.config.config import global_config
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -163,7 +162,17 @@ def find_messages(
|
||||
after_time=after_time,
|
||||
)
|
||||
if filter_bot:
|
||||
conditions.append(Messages.user_id != global_config.bot.qq_account)
|
||||
from src.chat.utils.utils import get_all_bot_accounts
|
||||
|
||||
bot_accounts = get_all_bot_accounts()
|
||||
if bot_accounts:
|
||||
bot_identity_predicate = or_(
|
||||
*[
|
||||
and_(Messages.platform == platform_name, Messages.user_id == account)
|
||||
for platform_name, account in bot_accounts.items()
|
||||
]
|
||||
)
|
||||
conditions.append(not_(bot_identity_predicate))
|
||||
if filter_command:
|
||||
conditions.append(Messages.is_command == False) # noqa: E712
|
||||
|
||||
|
||||
Reference in New Issue
Block a user