Refactoring codes for more tg message types
This commit is contained in:
@@ -6,7 +6,9 @@ import (
|
||||
query "github.com/tgckpg/golifehk/query"
|
||||
)
|
||||
|
||||
func Query(lang string, message string) query.IQueryResult {
|
||||
func Query(q query.QueryMessage) query.IQueryResult {
|
||||
|
||||
lang := q.Lang
|
||||
|
||||
var qBusStops *query.QueryObject
|
||||
var err error
|
||||
@@ -18,7 +20,14 @@ func Query(lang string, message string) query.IQueryResult {
|
||||
goto qrReturn
|
||||
}
|
||||
|
||||
qBusStops, err = query.Parse(strings.ToUpper(message), busStops)
|
||||
if q.Text != "" {
|
||||
qBusStops, err = query.MatchKeys(strings.ToUpper(q.Text), busStops)
|
||||
} else if q.Location != nil {
|
||||
qBusStops, err = query.MatchNearest(*q.Location, busStops, 100, 3)
|
||||
}
|
||||
|
||||
qBusStops.Message = &q
|
||||
|
||||
if err != nil {
|
||||
qr.Error = err
|
||||
goto qrReturn
|
||||
|
||||
Reference in New Issue
Block a user