fix: allow session cancellation in all states

Previously cancellation only worked in 'selecting' or 'ordering' states.
Now users can cancel server consultation at any stage using keywords:
취소, 다시, 처음, 리셋, 초기화, 다시 시작, 처음부터

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-27 11:26:54 +09:00
parent 8815654137
commit b1bbce5375
3 changed files with 101 additions and 15 deletions

View File

@@ -479,11 +479,16 @@ export async function processServerConsultation(
status: session.status
});
// 취소 키워드 처리 (selecting 또는 ordering 상태에서)
if ((session.status === 'selecting' || session.status === 'ordering') &&
/취소|다시|처음/.test(userMessage)) {
// 취소 키워드 처리 (모든 상태에서 작동)
// "취소", "다시", "처음", "리셋", "초기화" 등
if (/^(취소|다시|처음|리셋|초기화)/.test(userMessage.trim()) ||
/취소할[게래]|다시\s*시작|처음부터/.test(userMessage)) {
await deleteServerSession(env.SESSION_KV, session.telegramUserId);
logger.info('사용자 요청으로 상담 취소', { userId: session.telegramUserId });
logger.info('사용자 요청으로 상담 취소', {
userId: session.telegramUserId,
previousStatus: session.status,
trigger: userMessage.slice(0, 20)
});
return '상담이 취소되었습니다. 다시 시작하려면 "서버 추천"이라고 말씀해주세요.';
}