do the real matching: message <-> pattern
This commit is contained in:
parent
a2a47293a8
commit
5aa1cc07b6
1 changed files with 11 additions and 2 deletions
|
@ -44,8 +44,17 @@ func Select(ctx lib.Context, msg lib.Message) []lib.Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
func match(ac lib.ActionConfig, msg lib.Message) bool {
|
func match(ac lib.ActionConfig, msg lib.Message) bool {
|
||||||
return ac.Pattern().Slice()[0] == msg.Action()
|
pat := ac.Pattern().Slice()
|
||||||
//return false
|
if len(pat) == 1 {
|
||||||
|
return pat[0] == msg.Action()
|
||||||
|
}
|
||||||
|
mh := msg.Slice()
|
||||||
|
for idx, p := range pat {
|
||||||
|
if p != "" && mh[idx] != p {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// action handling
|
// action handling
|
||||||
|
|
Loading…
Add table
Reference in a new issue