package ignore import ( "context" "fmt" "regexp" "github.com/tcolgate/hugot" ) type HearsIgnore struct { hugot.HearsHandler Ignore []*regexp.Regexp } func NewHears(next hugot.HearsHandler, who ...string) hugot.HearsHandler { var ignoreCompiled []*regexp.Regexp for _, str := range who { ignoreCompiled = append(ignoreCompiled, regexp.MustCompile(str)) } return &HearsIgnore{HearsHandler: next, Ignore: ignoreCompiled} } func (i *HearsIgnore) Heard(ctx context.Context, w hugot.ResponseWriter, m *hugot.Message, matches [][]string) { for _, re := range i.Ignore { if re.MatchString(m.From) { return } } i.HearsHandler.Heard(ctx, w, m, matches) }