interaction: add PrivateCommand

This commit is contained in:
c9s 2022-01-13 23:41:22 +08:00
parent 76c64b041f
commit a6fb0caff3

View File

@ -30,7 +30,6 @@ const (
StateAuthenticated State = "authenticated"
)
type TextMessageResponder interface {
SetTextMessageResponder(responder Responder)
}
@ -47,8 +46,12 @@ type Messenger interface {
// Interact implements the interaction between bot and message software.
type Interact struct {
// commands is the default public command map
commands map[string]*Command
// privateCommands is the private command map, need auth
privateCommands map[string]*Command
states map[State]State
statesFunc map[State]interface{}
@ -75,6 +78,12 @@ func (i *Interact) AddCustomInteraction(custom CustomInteraction) {
custom.Commands(i)
}
func (i *Interact) PrivateCommand(command string, f interface{}) *Command {
cmd := NewCommand(command, f)
i.commands[command] = cmd
return cmd
}
func (i *Interact) Command(command string, f interface{}) *Command {
cmd := NewCommand(command, f)
i.commands[command] = cmd