diff --git a/dispatcher.go b/dispatcher.go index 4e1ba2f..434ac27 100644 --- a/dispatcher.go +++ b/dispatcher.go @@ -6,7 +6,6 @@ import ( type UpdateHandler func(u *Update) error type dispatchHandler func(u *Update) (bool, error) -type commandHandler func(u *UpdateCommand) error type Dispatcher struct { handlers []dispatchHandler @@ -26,7 +25,7 @@ func (d *Dispatcher) Run(u *Update) error { return nil } -func (d *Dispatcher) HandleCommand(command *Command, handler commandHandler) *Dispatcher { +func (d *Dispatcher) HandleCommand(command *Command, handler UpdateHandler) *Dispatcher { newHandler := func(u *Update) (bool, error) { if !strings.HasPrefix(u.Text(), command.String()) { return false, nil @@ -34,11 +33,7 @@ func (d *Dispatcher) HandleCommand(command *Command, handler commandHandler) *Di if command.IsAdminOnly && !u.IsUserAdmin() && u.ChatID() < 0 { return false, nil } - upd := &UpdateCommand{ - Update: *u, - Param: command.Param(u.Text()), - } - err := handler(upd) + err := handler(u) return true, err } d.handlers = append(d.handlers, newHandler)