Бот для капчи в чатах
Roman Sergienko
2026-10-10 cf4285e1e0ac8e76dc02729e64beb7cb28511fa1
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!doctype html>
<html lang="ru" class="dark">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
    <title>{% block title %}Amadeus{% endblock %}</title>
    <script>
        // Применяем сохранённую тему до отрисовки, чтобы не мигало.
        try { if (localStorage.getItem("amd-theme") === "light") document.documentElement.classList.remove("dark"); } catch (e) {}
    </script>
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            darkMode: "class",
            theme: {
                extend: {
                    fontFamily: { sans: ["Geist", "ui-sans-serif", "system-ui", "sans-serif"] },
                    colors: {
                        brand: {
                            50: "#eef2ff", 100: "#e0e7ff", 200: "#c7d2fe", 300: "#a5b4fc",
                            400: "#818cf8", 500: "#6366f1", 600: "#4f46e5", 700: "#4338ca",
                            800: "#3730a3", 900: "#312e81"
                        }
                    }
                }
            }
        }
    </script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="/static/style.css">
</head>
<body class="min-h-screen bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100 font-sans antialiased">
<div class="flex min-h-screen">
    <!-- Затемнение под мобильным меню -->
    <div id="backdrop" class="fixed inset-0 z-30 hidden bg-black/50 md:hidden"></div>
 
    <aside id="sidebar"
           class="fixed inset-y-0 left-0 z-40 flex w-64 shrink-0 -translate-x-full flex-col border-r border-gray-200 bg-white transition-transform duration-200 dark:border-gray-800 dark:bg-gray-900 md:static md:translate-x-0">
        <div class="flex h-16 items-center justify-between gap-2 border-b border-gray-200 px-5 dark:border-gray-800">
            <div class="flex items-center gap-2">
                <span class="relative inline-flex h-8 w-8 items-center justify-center overflow-hidden rounded-lg bg-brand-600 font-bold text-white">
                    A
                    <img src="/avatar/bot" alt="" class="absolute inset-0 h-full w-full object-cover" onerror="this.remove()">
                </span>
                <span class="text-lg font-semibold">Amadeus</span>
            </div>
            <button id="sidebar-close" class="rounded-lg p-1.5 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800 md:hidden" aria-label="Закрыть меню">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/></svg>
            </button>
        </div>
        <nav class="flex-1 space-y-1 overflow-y-auto p-3 text-sm">
            {% set items = [
                ("dash", "/", "Дашборд"),
                ("chats", "/chats", "Чаты"),
                ("users", "/users", "Пользователи"),
                ("captcha", "/captcha", "Активные капчи"),
                ("log", "/log", "Журнал")
            ] %}
            {% for key, href, label in items %}
            <a href="{{ href }}" onclick="closeSidebar()"
               class="flex items-center rounded-lg px-3 py-2.5 transition
               {% if active == key %}bg-brand-600 text-white shadow{% else %}text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800{% endif %}">
                {{ label }}
            </a>
            {% endfor %}
        </nav>
        <div class="border-t border-gray-200 p-3 dark:border-gray-800">
            <div class="flex items-center gap-3">
                {% if user and user.photo_url %}
                <img src="{{ user.photo_url }}" class="h-9 w-9 rounded-full object-cover" alt="">
                {% else %}
                <span class="inline-flex h-9 w-9 items-center justify-center rounded-full bg-gray-200 text-sm font-medium dark:bg-gray-700">
                    {{ (user.first_name or "?")[:1] }}
                </span>
                {% endif %}
                <div class="min-w-0">
                    <div class="truncate text-sm font-medium">{{ user.first_name or "Гость" }}</div>
                    <div class="truncate text-xs text-gray-500">{% if user.username %}@{{ user.username }}{% else %}id {{ user.user_id }}{% endif %}</div>
                </div>
            </div>
            <a href="/logout" class="mt-3 block rounded-lg border border-gray-200 px-3 py-1.5 text-center text-sm hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800">Выйти</a>
        </div>
    </aside>
 
    <div class="flex min-w-0 flex-1 flex-col">
        <header class="sticky top-0 z-20 flex h-16 items-center justify-between gap-3 border-b border-gray-200 bg-white/80 px-4 backdrop-blur dark:border-gray-800 dark:bg-gray-900/80 md:px-6">
            <div class="flex min-w-0 items-center gap-3">
                <button id="sidebar-open" class="rounded-lg border border-gray-200 p-2 text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800 md:hidden" aria-label="Открыть меню">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16"/></svg>
                </button>
                <h1 class="truncate text-lg font-semibold">{% block header %}{% endblock %}</h1>
            </div>
            <div class="flex items-center gap-2">
                <button id="theme-toggle" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800">Тема</button>
                <a href="/logout" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800 md:hidden">Выйти</a>
            </div>
        </header>
        <main class="space-y-6 p-4 md:p-6">
            {% block content %}{% endblock %}
        </main>
    </div>
</div>
 
<script>
    // Переключатель тёмной/светлой темы.
    document.getElementById("theme-toggle").addEventListener("click", function () {
        const root = document.documentElement;
        root.classList.toggle("dark");
        try { localStorage.setItem("amd-theme", root.classList.contains("dark") ? "dark" : "light"); } catch (e) {}
    });
 
    // Мобильное меню-«шторка».
    const sidebar = document.getElementById("sidebar");
    const backdrop = document.getElementById("backdrop");
    function openSidebar() {
        sidebar.classList.remove("-translate-x-full");
        backdrop.classList.remove("hidden");
    }
    function closeSidebar() {
        sidebar.classList.add("-translate-x-full");
        backdrop.classList.add("hidden");
    }
    document.getElementById("sidebar-open").addEventListener("click", openSidebar);
    document.getElementById("sidebar-close").addEventListener("click", closeSidebar);
    backdrop.addEventListener("click", closeSidebar);
    document.addEventListener("keydown", function (e) { if (e.key === "Escape") closeSidebar(); });
</script>
</body>
</html>