penguin/golifehk

@golifehk bot in Telegram

commit f5188e1abaf39a868cd297e4c29a26e17c97f0f6

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-06-20T08:06:24Z
subjectKMB: Do not search BusStopId unless fully qualified
commit f5188e1abaf39a868cd297e4c29a26e17c97f0f6
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-06-20T08:06:24Z

    KMB: Do not search BusStopId unless fully qualified
---
 datasources/kmb/BusStop.go   |  1 -
 datasources/kmb/RouteStop.go | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/datasources/kmb/BusStop.go b/datasources/kmb/BusStop.go
index b77e645..c8a7b81 100644
--- a/datasources/kmb/BusStop.go
+++ b/datasources/kmb/BusStop.go
@@ -41,7 +41,6 @@ func (b BusStop) Register(registers map[string]struct{}) bool {
 
 func (this *BusStop) Reload() {
 	searchData := []*string{}
-	searchData = append(searchData, &this.BusStopId)
 
 	if this.Name != nil {
 		for _, v := range *this.Name {
diff --git a/datasources/kmb/RouteStop.go b/datasources/kmb/RouteStop.go
index 6e2ec8c..ac462a4 100644
--- a/datasources/kmb/RouteStop.go
+++ b/datasources/kmb/RouteStop.go
@@ -1,6 +1,8 @@
 package kmb
 
 import (
+	"strings"
+
 	query "github.com/tgckpg/golifehk/query"
 )
 
@@ -38,8 +40,41 @@ func (routeStop RouteStop) NextStop() *RouteStop {
 	return nil
 }
 
-func (this *RouteStop) Reload() {
+func isUpperHex16(s string) bool {
+	if len(s) != 16 {
+		return false
+	}
+
+	for i := 0; i < 16; i++ {
+		c := s[i]
+		if (c < '0' || c > '9') && (c < 'A' || c > 'F') {
+			return false
+		}
+	}
+
+	return true
+}
+
+func (this *RouteStop) Test(val string) bool {
 
+	if isUpperHex16(val) {
+		return (this.BusStop.BusStopId == val)
+	}
+
+	data := this.SearchData
+	if data == nil {
+		return false
+	}
+
+	for _, v := range *data {
+		if strings.Contains(*v, val) {
+			return true
+		}
+	}
+	return false
+}
+
+func (this *RouteStop) Reload() {
 	this.Key = &this.RouteId
 	this.SearchData = this.BusStop.SearchData
 }