from .database import get_db def check_sensitive_words(*texts): """ 检查文本中是否包含敏感词 返回 (found, word) - found为True时word为匹配到的敏感词 """ conn = get_db() cursor = conn.cursor() try: cursor.execute('SELECT word FROM sensitive_words') words = [row['word'] for row in cursor.fetchall()] finally: conn.close() if not words: return False, None for text in texts: if not text: continue text_lower = str(text).lower() for word in words: if word.lower() in text_lower: return True, word return False, None