From 0063b156cc2853718095d655208d3eeef6f68ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Sat, 13 Jun 2026 08:16:52 +0800 Subject: [PATCH] Handle unsupported message --- datasources/kmb/query.go | 4 ++++ datasources/mtr/bus/query.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/datasources/kmb/query.go b/datasources/kmb/query.go index 72948ec..96068c8 100644 --- a/datasources/kmb/query.go +++ b/datasources/kmb/query.go @@ -1,6 +1,7 @@ package kmb import ( + "fmt" query "github.com/tgckpg/golifehk/query" "log" "strings" @@ -42,6 +43,9 @@ func Query(q query.QueryMessage) query.IQueryResult { } qo, err = query.MatchNearest(*q.Location, &bList, qr.NearestRange, qr.FallbackNearest) + } else { + qr.Error = fmt.Errorf("unsupported message") + goto qrReturn } qo.Message = &q diff --git a/datasources/mtr/bus/query.go b/datasources/mtr/bus/query.go index 52e8b00..b5690d3 100644 --- a/datasources/mtr/bus/query.go +++ b/datasources/mtr/bus/query.go @@ -1,6 +1,7 @@ package bus import ( + "fmt" "strings" query "github.com/tgckpg/golifehk/query" @@ -29,6 +30,9 @@ func Query(q query.QueryMessage) query.IQueryResult { qBusStops, err = query.MatchKeys(strings.ToUpper(q.Text), busStops) } else if q.Location != nil { qBusStops, err = query.MatchNearest(*q.Location, busStops, qr.NearestRange, qr.FallbackNearest) + } else { + qr.Error = fmt.Errorf("unsupported message") + goto qrReturn } if err != nil {