diff --git a/src/handlers/user.py b/src/handlers/user.py index 006598d..d0b92b1 100644 --- a/src/handlers/user.py +++ b/src/handlers/user.py @@ -14,6 +14,7 @@ from guard import is_academic_topic, REJECT_MESSAGE _pending_confirmations: dict = {} REMINDER_KEYWORDS = ["ingatkan", "pengingat", "remind", "jadwalkan", "tolong ingat"] +REMINDER_BYPASS_KEYWORDS = ["ingatkan", "pengingat", "remind", "diingatkan", "jadwalkan", "kapan diingat"] _client = AsyncOpenAI(api_key=DEEPSEEK_API_KEY, base_url=DEEPSEEK_BASE_URL) @@ -316,6 +317,8 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE): # Deteksi intent reminder dari plain text text_lower = text.lower() + is_reminder_related = any(kw in text_lower for kw in REMINDER_BYPASS_KEYWORDS) + if any(kw in text_lower for kw in REMINDER_KEYWORDS): await update.message.chat.send_action("typing") parsed = await reminder_module.parse_reminder_intent(text, _client, DEEPSEEK_MODEL) @@ -327,9 +330,11 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE): question = text await update.message.chat.send_action("typing") - if not await is_academic_topic(question, _client, DEEPSEEK_MODEL): - await update.message.reply_text(REJECT_MESSAGE) - return + # Skip guard untuk pertanyaan tentang fitur bot sendiri + if not is_reminder_related: + if not await is_academic_topic(question, _client, DEEPSEEK_MODEL): + await update.message.reply_text(REJECT_MESSAGE) + return relevant = await rag.search(user_data["id"], question, n_results=5) context_text = ""