diff --git a/bot.go b/bot.go index 118c29f..74b3670 100644 --- a/bot.go +++ b/bot.go @@ -21,9 +21,6 @@ type bot struct { func DefaultHandler(u *Update) error { err := u.Bot.state.Call(u) - if err != nil { - u.LogError("", err, true) - } return err } diff --git a/dispatcher.go b/dispatcher.go index 36da8d1..4e1ba2f 100644 --- a/dispatcher.go +++ b/dispatcher.go @@ -56,3 +56,18 @@ func (d *Dispatcher) HandleFilter(filter FilterFn, handler UpdateHandler) *Dispa d.handlers = append(d.handlers, newHandler) return d } + +func (d *Dispatcher) HandleReply(handler UpdateHandler) *Dispatcher { + newHandler := func(u *Update) (bool, error) { + if !u.IsMessage() { + return false, nil + } + if u.Message.ReplyToMessage == nil { + return false, nil + } + err := handler(u) + return true, err + } + d.handlers = append(d.handlers, newHandler) + return d +} diff --git a/filters.go b/filters.go index 6e81259..1bfb9ce 100644 --- a/filters.go +++ b/filters.go @@ -10,8 +10,32 @@ func TextStartsWith(text string) FilterFn { } } +func TextStartsWithAny(subs ...string) FilterFn { + return func(u *Update) bool { + text := u.Text() + for _, sub := range subs { + if strings.HasPrefix(text, sub) { + return true + } + } + return false + } +} + func TextHas(text string) FilterFn { return func(u *Update) bool { return strings.Contains(u.Text(), text) } } + +func TextHasAny(subs ...string) FilterFn { + return func(u *Update) bool { + text := u.Text() + for _, sub := range subs { + if strings.Contains(text, sub) { + return true + } + } + return false + } +}