File size: 1,047 Bytes
4ae4ae8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Crisis detection and response."""

from __future__ import annotations

import config


def detect_crisis(text: str) -> bool:
    """Check if user message contains crisis indicators."""
    text_lower = text.lower()
    return any(kw in text_lower for kw in config.CRISIS_KEYWORDS)


def get_crisis_response() -> str:
    """Get the warm crisis response message."""
    return (
        "I hear you. What you're feeling right now matters, "
        "and you don't have to go through this alone."
    )


def get_crisis_banner_html() -> str:
    """Render crisis helpline banner as HTML."""
    lines = []
    for h in config.HELPLINES:
        lines.append(f"<div class='helpline'><strong>{h['name']}</strong> — {h['contact']}</div>")

    return f"""
    <div class="crisis-banner">
        <div class="crisis-header">💜 You're not alone. Help is available:</div>
        {''.join(lines)}
        <div class="crisis-footer">I'm still here. We can keep talking, or try a grounding exercise — whatever feels right.</div>
    </div>
    """