From 906c769453d328e640bae3e9618c67a7d4b478bd Mon Sep 17 00:00:00 2001 From: nefrace Date: Tue, 24 Jan 2023 01:12:19 +0300 Subject: [PATCH] Removed command handler --- dispatcher.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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)