feat(lifecycle): /window + stop screenshot-uri la închiderea bursei
Fix #1: la tranziția market_closed scheduler-ul e oprit forțat și FSM resetat la IDLE (_handle_market_closed), ca o bulină dark_* rămasă PRIMED să nu mai trimită screenshot-uri periodice după închidere — și ca scheduler-ul să poată reporni curat în sesiunea următoare (muchia 0->1 n_primed_global). Fix #2: comandă Telegram /window HH:MM-HH:MM (sau HH:MM HH:MM) — fereastră de monitorizare în ora locală, recurentă zilnic, ANDed cu operating_hours; în afara intervalului pauză automată. /window off șterge fereastra. Discord e webhook outbound, fără poller — comanda e doar Telegram. DOX pass: src/atm + notifier. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -65,3 +65,39 @@ def test_parse_existing_commands_still_work():
|
||||
assert p._parse_command("status") == Command(action="status")
|
||||
assert p._parse_command("ss") == Command(action="ss")
|
||||
assert p._parse_command("3") == Command(action="set_interval", value=180)
|
||||
|
||||
|
||||
def test_parse_window_dash():
|
||||
p = _make_poller()
|
||||
cmd = p._parse_command("window 19:40-21:45")
|
||||
assert cmd == Command(action="window", window=("19:40", "21:45"))
|
||||
assert p._parse_command("/window 19:40-21:45") == cmd
|
||||
|
||||
|
||||
def test_parse_window_space():
|
||||
p = _make_poller()
|
||||
assert p._parse_command("window 20:50 22:45") == Command(
|
||||
action="window", window=("20:50", "22:45")
|
||||
)
|
||||
|
||||
|
||||
def test_parse_window_zero_pads_hour():
|
||||
p = _make_poller()
|
||||
assert p._parse_command("window 9:05-9:30") == Command(
|
||||
action="window", window=("09:05", "09:30")
|
||||
)
|
||||
|
||||
|
||||
def test_parse_window_off_clears():
|
||||
p = _make_poller()
|
||||
assert p._parse_command("window off") == Command(action="window", window=None)
|
||||
assert p._parse_command("window") == Command(action="window", window=None)
|
||||
assert p._parse_command("window clear") == Command(action="window", window=None)
|
||||
|
||||
|
||||
def test_parse_window_invalid_returns_none():
|
||||
p = _make_poller()
|
||||
assert p._parse_command("window 25:99-26:00") is None
|
||||
assert p._parse_command("window foo") is None
|
||||
assert p._parse_command("window 19:40") is None
|
||||
assert p._parse_command("window 19:60-20:00") is None
|
||||
|
||||
Reference in New Issue
Block a user