captsa add alert

This commit is contained in:
2026-04-21 19:17:28 +03:00
parent 7e5bfcefa4
commit b0d933c1a0
9 changed files with 162 additions and 6 deletions

View File

@@ -122,3 +122,25 @@ def command_result(cmd_id):
conn.commit()
conn.close()
return jsonify({'ok': True})
# ------------------------------------------------------------------
# POST /api/captcha/alert
# Tampermonkey reports when #hcaptcha_window appears/disappears.
# Body: { detected: true | false }
# ------------------------------------------------------------------
@api.route('/api/captcha/alert', methods=['POST'])
def captcha_alert():
data = request.get_json(silent=True) or {}
detected = bool(data.get('detected', False))
conn = get_db()
conn.execute('''
INSERT INTO kv_store (key, value, updated_at)
VALUES ('captcha_active', ?, ?)
ON CONFLICT(key) DO UPDATE SET
value = excluded.value,
updated_at = excluded.updated_at
''', ('1' if detected else '0', datetime.utcnow().isoformat()))
conn.commit()
conn.close()
return jsonify({'ok': True})

View File

@@ -94,6 +94,21 @@ def client_status():
return jsonify({'online': online, 'last_seen': last_seen})
# ------------------------------------------------------------------
# GET /dashboard/captcha-status
# Returns whether a captcha is currently active in the game client.
# ------------------------------------------------------------------
@dashboard.route('/dashboard/captcha-status', methods=['GET'])
def captcha_status():
conn = get_db()
row = conn.execute(
"SELECT value FROM kv_store WHERE key = 'captcha_active'"
).fetchone()
conn.close()
active = bool(row and row['value'] == '1')
return jsonify({'captcha_active': active})
# ------------------------------------------------------------------
# GET /dashboard/commands
# Returns command history (last 50) for the log panel.