Refactoring codes for more tg message types
This commit is contained in:
43
query/Words.go
Normal file
43
query/Words.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Words struct {
|
||||
Key *string
|
||||
SearchData *[]*string
|
||||
}
|
||||
|
||||
func (this *Words) HasWords() bool { return true }
|
||||
|
||||
func (this *Words) Test(val string) bool {
|
||||
|
||||
data := this.SearchData
|
||||
if data == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, v := range *data {
|
||||
if strings.Contains(*v, val) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *Words) GetKey() *string {
|
||||
return this.Key
|
||||
}
|
||||
|
||||
type ByKey []ISearchable
|
||||
|
||||
func (a ByKey) Len() int { return len(a) }
|
||||
func (a ByKey) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByKey) Less(i, j int) bool { return *a[i].GetKey() < *a[j].GetKey() }
|
||||
|
||||
type NoWords struct{}
|
||||
|
||||
func (this NoWords) HasWords() bool { return false }
|
||||
func (this NoWords) Test(val string) bool { return false }
|
||||
func (this NoWords) GetKey() *string { return nil }
|
||||
Reference in New Issue
Block a user