File size: 698 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package harness
import "strings"
func containsAllIgnoreCase(s string, substrs []string) bool {
s = strings.ToLower(s)
for _, sub := range substrs {
if !strings.Contains(s, strings.ToLower(sub)) {
return false
}
}
return true
}
type messageMatcher struct {
number string
keywords []string
}
type devMessage interface {
To() string
Body() string
}
func (m messageMatcher) match(msg devMessage) bool {
return strings.TrimPrefix(msg.To(), "rcs:") == m.number && containsAllIgnoreCase(msg.Body(), m.keywords)
}
type anyMessage []messageMatcher
func (any anyMessage) match(msg devMessage) bool {
for _, m := range any {
if m.match(msg) {
return true
}
}
return false
}
|