# Test user_states va handle_fail_reason
user_states = {}
chat_id = 12345
deal_id = '89'
message_id = 100
ask_msg_id = 101

# Simulate callback - Не успешно bosildi
user_states[chat_id] = {
    'action': 'waiting_fail_reason',
    'deal_id': deal_id,
    'message_id': message_id,
    'ask_msg_id': ask_msg_id
}

print('After button click:')
print(f'user_states: {user_states}')
print(f'chat_id in user_states: {chat_id in user_states}')
print(f'action: {user_states.get(chat_id, {}).get("action")}')
print()

# Simulate message received
reason = 'tel kotarmadi'
print(f'Reason received: "{reason}"')
print(f'Length: {len(reason)} (min 3)')

# Check condition from handler
check = chat_id in user_states and user_states.get(chat_id, {}).get('action') == 'waiting_fail_reason'
print(f'Handler condition check: {check}')

if len(reason) >= 3:
    print('✅ Reason accepted!')
    state = user_states[chat_id]
    print(f'Deal ID: {state["deal_id"]}')
    print(f'Original message ID: {state["message_id"]}')
    
    # Clear state
    del user_states[chat_id]
    print(f'user_states after clear: {user_states}')
else:
    print('❌ Reason too short!')
