Redesign: Start/Stop buttons, locked settings, queue countdown, wb2 logo
- Replace tumbler with Start/Stop buttons (green/red) - Lock settings form with <fieldset disabled> when auto-reply active - Clear queue + reset fetch timer on settings save - Show 'Очередь подгрузится через X сек.' countdown in queue section - API /status returns next_fetch_seconds, queue_len, auto_reply_enabled - Login: price 15₽/день, up to 144 replies/day, wb2 logo, promo panel 25% width - Replace wb.png → wb2.png across all templates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1051,6 +1051,17 @@ def _next_auto_reply_meta() -> Tuple[Optional[datetime], Optional[int]]:
|
||||
return next_dt, seconds_left
|
||||
|
||||
|
||||
def _next_fetch_seconds_left() -> int:
|
||||
raw = db.get_setting(AUTO_REPLY_LAST_FETCH_KEY)
|
||||
if not raw:
|
||||
return 0
|
||||
try:
|
||||
last_fetch = float(raw)
|
||||
except ValueError:
|
||||
return 0
|
||||
return max(0, int(last_fetch + AUTO_REPLY_FETCH_INTERVAL_SECONDS - time.time()))
|
||||
|
||||
|
||||
def auto_reply_loop() -> None:
|
||||
while True:
|
||||
try:
|
||||
@@ -1275,6 +1286,8 @@ def index():
|
||||
success_message = f"Отправлено ответов: {count}"
|
||||
elif status == "pools_saved":
|
||||
success_message = "Пулы автоответов сохранены."
|
||||
elif status == "settings_saved":
|
||||
success_message = "Настройки сохранены. Очередь будет обновлена."
|
||||
elif status == "reply_failed":
|
||||
error_text = request.args.get("error") or "Не удалось отправить ответы."
|
||||
error_message = error_text
|
||||
@@ -1297,11 +1310,10 @@ def index():
|
||||
next_auto_reply_at=next_auto_reply_at,
|
||||
next_auto_reply_in_seconds=next_auto_reply_in_seconds,
|
||||
api_cooldown_seconds_left=api_cooldown_seconds_left,
|
||||
next_fetch_seconds_left=_next_fetch_seconds_left(),
|
||||
enabled_stars=list(_load_enabled_stars()),
|
||||
filter_mode=_load_filter_mode(),
|
||||
reply_pools={n: _pool_to_multiline_text(_load_reply_pool(n)) for n in range(1, 6)},
|
||||
reply_pool_5_list=_load_reply_pool(5),
|
||||
reply_pool_4_list=_load_reply_pool(4),
|
||||
auto_reply_queue=_load_auto_reply_queue(),
|
||||
auto_reply_logs=db.list_auto_reply_logs(limit=100),
|
||||
current_user=g.user,
|
||||
@@ -1319,7 +1331,15 @@ def api_status():
|
||||
logs = db.list_auto_reply_logs(limit=1)
|
||||
last_id = logs[0]["id"] if logs else None
|
||||
cooldown = _get_api_cooldown_seconds_left()
|
||||
return jsonify({"last_log_id": last_id, "cooldown": cooldown})
|
||||
next_fetch = _next_fetch_seconds_left()
|
||||
queue_len = len(_load_auto_reply_queue())
|
||||
return jsonify({
|
||||
"last_log_id": last_id,
|
||||
"cooldown": cooldown,
|
||||
"next_fetch_seconds": next_fetch,
|
||||
"queue_len": queue_len,
|
||||
"auto_reply_enabled": is_auto_reply_enabled(),
|
||||
})
|
||||
|
||||
|
||||
@app.route("/auto-reply-toggle", methods=["POST"])
|
||||
@@ -1327,7 +1347,7 @@ def api_status():
|
||||
def auto_reply_toggle():
|
||||
enabled = request.form.get("enabled") == "1"
|
||||
set_auto_reply_enabled(enabled)
|
||||
return redirect(url_for("index", action="unanswered", stars=[5, 4]))
|
||||
return redirect(url_for("index"))
|
||||
|
||||
|
||||
@app.route("/auto-reply-pools", methods=["POST"])
|
||||
@@ -1358,18 +1378,22 @@ def auto_reply_pools():
|
||||
@app.route("/auto-reply-settings", methods=["POST"])
|
||||
@login_required
|
||||
def auto_reply_settings():
|
||||
if is_auto_reply_enabled():
|
||||
return redirect(url_for("index"))
|
||||
stars = [int(s) for s in request.form.getlist("stars") if s.isdigit() and 1 <= int(s) <= 5]
|
||||
filter_mode = request.form.get("filter_mode", "no_text")
|
||||
if filter_mode not in ("no_text", "empty", "all"):
|
||||
filter_mode = "no_text"
|
||||
db.set_setting(AUTO_REPLY_STARS_KEY, json.dumps(stars))
|
||||
db.set_setting(AUTO_REPLY_FILTER_KEY, filter_mode)
|
||||
# Save pools for each enabled star
|
||||
for star in range(1, 6):
|
||||
items = [i.strip() for i in request.form.getlist(f"pool_{star}_item") if i.strip()]
|
||||
if items:
|
||||
db.set_setting(f"auto_reply_pool_{star}", _pool_to_multiline_text(items))
|
||||
return redirect(url_for("index", status="pools_saved"))
|
||||
# Clear queue and reset fetch window so next cycle rebuilds immediately
|
||||
db.set_setting("auto_reply_queue_json", "[]")
|
||||
db.set_setting(AUTO_REPLY_LAST_FETCH_KEY, "0")
|
||||
return redirect(url_for("index", status="settings_saved"))
|
||||
|
||||
|
||||
@app.route("/reply", methods=["POST"])
|
||||
|
||||
Reference in New Issue
Block a user