diff --git a/internal/modules/lolschedule/cron.go b/internal/modules/lolschedule/cron.go index 5ac74e2..f628604 100644 --- a/internal/modules/lolschedule/cron.go +++ b/internal/modules/lolschedule/cron.go @@ -188,6 +188,7 @@ func runDailyPush(ctx context.Context, s *state, sender messageSender) error { } filtered := FilterMajor(events) text := RenderToday(filtered, from) + disableNotification := len(filtered) == 0 // Idempotency gate: claim today's push before sending. A lost claim means // another trigger already pushed (or is pushing) for this UTC date, so we @@ -216,10 +217,11 @@ func runDailyPush(ctx context.Context, s *state, sender messageSender) error { } } if _, err := sender.SendMessage(ctx, &bot.SendMessageParams{ - ChatID: sub.ChatID, - MessageThreadID: sub.ThreadID, - Text: text, - ParseMode: models.ParseModeHTML, + ChatID: sub.ChatID, + MessageThreadID: sub.ThreadID, + Text: text, + ParseMode: models.ParseModeHTML, + DisableNotification: disableNotification, }); err != nil { log.Warn("lolschedule daily push send failed", "chat", sub.ChatID, "thread", sub.ThreadID, "err", err) diff --git a/internal/modules/lolschedule/cron_test.go b/internal/modules/lolschedule/cron_test.go index a97fa85..0975648 100644 --- a/internal/modules/lolschedule/cron_test.go +++ b/internal/modules/lolschedule/cron_test.go @@ -106,7 +106,7 @@ func TestRunDailyPush_NoSubscribers(t *testing.T) { } } -func TestRunDailyPush_SendsToAllSubscribers(t *testing.T) { +func TestRunDailyPush_SendsEmptyScheduleSilently(t *testing.T) { s := newTestState(t) seedFreshCache(t, s.cache, nil) // empty schedule still produces a "no matches" message @@ -142,6 +142,37 @@ func TestRunDailyPush_SendsToAllSubscribers(t *testing.T) { if call.MessageThreadID != 0 { t.Errorf("send %d: thread got %d, want 0 (no topic)", i, call.MessageThreadID) } + if !call.DisableNotification { + t.Errorf("send %d: DisableNotification got false, want true for empty schedule", i) + } + } +} + +func TestRunDailyPush_SendsMatchScheduleWithNotification(t *testing.T) { + s := newTestState(t) + seedFreshCache(t, s.cache, []ScheduleEvent{{ + StartTime: "2026-05-10T06:00:00Z", + State: "unstarted", + League: League{Name: "LCK", Slug: "lck"}, + Match: Match{ + Teams: []Team{{Code: "T1"}, {Code: "GEN"}}, + Strategy: Strategy{Count: 3}, + }, + }}) + + if _, err := addSubscriber(context.Background(), s.subscribers, 100, 0); err != nil { + t.Fatalf("addSubscriber: %v", err) + } + + sender := &fakeSender{} + if err := runDailyPush(context.Background(), s, sender); err != nil { + t.Fatalf("runDailyPush: %v", err) + } + if len(sender.calls) != 1 { + t.Fatalf("expected 1 send, got %d", len(sender.calls)) + } + if sender.calls[0].DisableNotification { + t.Fatalf("DisableNotification got true, want false when today's match list is non-empty") } }