Бот для капчи в чатах
web/templates/users.html
@@ -3,64 +3,47 @@
{% block header %}Пользователи{% endblock %}
{% block content %}
<section class="rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
    <div class="px-5 py-3 border-b border-gray-200 dark:border-gray-800 font-semibold">Активные наказания</div>
    <div class="overflow-x-auto">
        <table class="w-full text-sm">
            <thead class="bg-gray-50 dark:bg-gray-900/60 text-gray-500 dark:text-gray-400">
                <tr>
                    <th class="px-5 py-3 text-left font-medium">Пользователь</th>
                    <th class="px-5 py-3 text-left font-medium">Чат</th>
                    <th class="px-5 py-3 text-left font-medium">Тип</th>
                    <th class="px-5 py-3 text-left font-medium">Срок</th>
                    <th class="px-5 py-3 text-left font-medium">Выдан</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-100 dark:divide-gray-800">
                {% for p in rows %}
                <tr class="hover:bg-gray-50 dark:hover:bg-gray-800/50">
                    <td class="px-5 py-3">
                        <a class="text-brand-500 hover:underline" href="/users/{{ p.chat_id }}/{{ p.user_id }}">{{ p.user_id }}</a>
                        <div class="text-xs text-gray-500">{{ p.reason or "-" }}</div>
                    </td>
                    <td class="px-5 py-3">{{ names.get(p.chat_id, p.chat_id) }}</td>
                    <td class="px-5 py-3">{{ "мут" if p.kind == "mute" else "бан" }}</td>
                    <td class="px-5 py-3">{{ fmt_dur(p.until) if p.until else "бессрочно" }}</td>
                    <td class="px-5 py-3 text-gray-500">{{ fmt_dt(p.created_at) }}</td>
                </tr>
                {% else %}
                <tr><td colspan="5" class="px-5 py-8 text-center text-gray-500">Активных наказаний нет.</td></tr>
                {% endfor %}
            </tbody>
        </table>
<section class="space-y-3">
    <h2 class="text-sm font-semibold text-gray-500 dark:text-gray-400">Активные наказания</h2>
    <div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
        {% for p in rows %}
        <a href="/users/{{ p.chat_id }}/{{ p.user_id }}"
           class="block rounded-xl border border-gray-200 bg-white p-4 shadow-sm transition hover:border-brand-400 dark:border-gray-800 dark:bg-gray-900 dark:hover:border-brand-500">
            <div class="flex items-center justify-between gap-2">
                <span class="font-semibold text-brand-600 dark:text-brand-400">{{ p.user_id }}</span>
                <span class="rounded-full px-2 py-0.5 text-xs
                    {% if p.kind == 'ban' %}bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300{% else %}bg-amber-100 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300{% endif %}">
                    {{ "бан" if p.kind == "ban" else "мут" }}
                </span>
            </div>
            <div class="mt-1 truncate text-xs text-gray-500">{{ names.get(p.chat_id, p.chat_id) }}</div>
            <div class="mt-2 text-sm">Срок: {{ fmt_dur(p.until) if p.until else "бессрочно" }}</div>
            <div class="mt-1 line-clamp-2 text-xs text-gray-500">{{ p.reason or "без причины" }} · {{ fmt_dt(p.created_at) }}</div>
        </a>
        {% else %}
        <div class="rounded-xl border border-gray-200 bg-white p-8 text-center text-gray-500 dark:border-gray-800 dark:bg-gray-900 sm:col-span-2 xl:col-span-3">
            Активных наказаний нет.
        </div>
        {% endfor %}
    </div>
</section>
<section class="rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
    <div class="px-5 py-3 border-b border-gray-200 dark:border-gray-800 font-semibold">Предупреждения</div>
    <div class="overflow-x-auto">
        <table class="w-full text-sm">
            <thead class="bg-gray-50 dark:bg-gray-900/60 text-gray-500 dark:text-gray-400">
                <tr>
                    <th class="px-5 py-3 text-left font-medium">Пользователь</th>
                    <th class="px-5 py-3 text-left font-medium">Чат</th>
                    <th class="px-5 py-3 text-left font-medium">Причина</th>
                    <th class="px-5 py-3 text-left font-medium">Добавлен</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-100 dark:divide-gray-800">
                {% for w in warns %}
                <tr class="hover:bg-gray-50 dark:hover:bg-gray-800/50">
                    <td class="px-5 py-3"><a class="text-brand-500 hover:underline" href="/users/{{ w.chat_id }}/{{ w.user_id }}">{{ w.user_id }}</a></td>
                    <td class="px-5 py-3">{{ names.get(w.chat_id, w.chat_id) }}</td>
                    <td class="px-5 py-3">{{ w.reason or "-" }}</td>
                    <td class="px-5 py-3 text-gray-500">{{ fmt_dt(w.created_at) }}</td>
                </tr>
                {% else %}
                <tr><td colspan="4" class="px-5 py-8 text-center text-gray-500">Предупреждений нет.</td></tr>
                {% endfor %}
            </tbody>
        </table>
<section class="space-y-3">
    <h2 class="text-sm font-semibold text-gray-500 dark:text-gray-400">Предупреждения</h2>
    <div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
        {% for w in warns %}
        <a href="/users/{{ w.chat_id }}/{{ w.user_id }}"
           class="block rounded-xl border border-gray-200 bg-white p-4 shadow-sm transition hover:border-brand-400 dark:border-gray-800 dark:bg-gray-900 dark:hover:border-brand-500">
            <div class="font-semibold text-brand-600 dark:text-brand-400">{{ w.user_id }}</div>
            <div class="mt-1 truncate text-xs text-gray-500">{{ names.get(w.chat_id, w.chat_id) }}</div>
            <div class="mt-2 line-clamp-2 text-sm">{{ w.reason or "без причины" }}</div>
            <div class="mt-1 text-xs text-gray-500">{{ fmt_dt(w.created_at) }}</div>
        </a>
        {% else %}
        <div class="rounded-xl border border-gray-200 bg-white p-8 text-center text-gray-500 dark:border-gray-800 dark:bg-gray-900 sm:col-span-2 xl:col-span-3">
            Предупреждений нет.
        </div>
        {% endfor %}
    </div>
</section>