Fix #14: Refactor print_browse/send_to_telegram into single pipeline #22
Reference in New Issue
Block a user
Delete Branch "fix/issue-14-refactor-browse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replace duplicate inline formatting in
print_browse()andsend_to_telegram()with a unified format+render pipeline.New Functions
format_match_event(e)— canonical dict for match events (stateless, pure)format_non_match_event(e)— canonical dict for non-match eventsrender_match_lines(event_dict, i, mode)— renders lines, mode=text|htmlrender_non_match_lines(event_dict, i, mode)— same for non-match eventssend_chunked(...)— extracted Telegram chunking logicPipeline
Design principles:
format_*()are pure (one event in, dict out)render_*()is mode-aware (text vs HTML escaping)browse_events()stays simple — no pre-computationBug Fix
send_chunked()chunking condition was broken: the original". " in linecheck never matched event lines since the period is followed by</b>, not a space. Fixed to just check</a>presence.Test Coverage
19 new tests (38 total, all passing).
Lines Changed
print_browse(): ~80 lines -> ~25 linessend_to_telegram(): ~120 lines -> ~35 linesFixes: #14
d018e87b35to3a9f8fb365