Removed command handler
This commit is contained in:
parent
d797a52029
commit
906c769453
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue