Init barebones Go Telegram bot with commands folder similar to the JS bot
This commit is contained in:
19
commands/command.go
Normal file
19
commands/command.go
Normal file
@ -0,0 +1,19 @@
|
||||
package commands
|
||||
|
||||
import tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
|
||||
type Command interface {
|
||||
Name() string
|
||||
Help() string
|
||||
Execute(update tgbotapi.Update, bot *tgbotapi.BotAPI)
|
||||
}
|
||||
|
||||
var commandRegistry = make(map[string]Command)
|
||||
|
||||
func Register(cmd Command) {
|
||||
commandRegistry[cmd.Name()] = cmd
|
||||
}
|
||||
|
||||
func All() map[string]Command {
|
||||
return commandRegistry
|
||||
}
|
Reference in New Issue
Block a user