Init barebones Go Telegram bot with commands folder similar to the JS bot

This commit is contained in:
2025-05-28 12:08:44 +02:00
parent f5302c3dbf
commit 2c4ac42019
7 changed files with 124 additions and 1 deletions

28
commands/info.go Normal file
View File

@ -0,0 +1,28 @@
package commands
import (
"log"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
type InfoCommand struct{}
func (i InfoCommand) Name() string {
return "info"
}
func (i InfoCommand) Help() string {
return "Displays information about the bot."
}
func (i InfoCommand) Execute(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "This bot does XYZ.")
_, err := bot.Send(msg)
if err != nil {
log.Println("Failed to send info message:", err)
}
}
func init() {
Register(InfoCommand{})
}