fixxes soundboard auto-start

This commit is contained in:
2026-02-19 09:10:41 +01:00
parent 14108a8077
commit e1f068f97f
2 changed files with 52 additions and 3 deletions
+17 -1
View File
@@ -131,6 +131,7 @@ def _auto_random_tick():
delay = rand_between(imin, imax) * 60
with auto_random_lock:
if state.auto_random_active:
auto_random_params['next_ts'] = time.time() + delay
auto_random_timer = threading.Timer(delay, _auto_random_tick)
auto_random_timer.daemon = True
auto_random_timer.start()
@@ -436,6 +437,7 @@ def api_soundboard_auto_start():
auto_random_params['imax'] = imax
auto_random_params['dmin'] = dmin
auto_random_params['dmax'] = dmax
auto_random_params['next_ts'] = time.time() + delay
global auto_random_timer
auto_random_timer = threading.Timer(delay, _auto_random_tick)
auto_random_timer.daemon = True
@@ -455,7 +457,20 @@ def api_soundboard_auto_stop():
def api_soundboard_status():
with auto_random_lock:
active = state.auto_random_active
return jsonify({"active": active})
next_ts = auto_random_params.get('next_ts')
imin = auto_random_params.get('imin')
imax = auto_random_params.get('imax')
dmin = auto_random_params.get('dmin')
dmax = auto_random_params.get('dmax')
next_seconds = max(0, next_ts - time.time()) if next_ts else None
return jsonify({
"active": active,
"next_seconds": next_seconds,
"interval_min": imin,
"interval_max": imax,
"delay_min": dmin,
"delay_max": dmax
})
def _stop_auto_random_internal():
@@ -467,6 +482,7 @@ def _stop_auto_random_internal():
auto_random_timer = None
stopped = True
state.auto_random_active = False
auto_random_params.clear()
return stopped