1
0
Fork 0

Initial stub of command support

This commit is contained in:
Michał Rudowicz 2025-01-09 21:53:58 +01:00
parent f2e5684477
commit cbc3d68c95
1 changed files with 42 additions and 0 deletions

42
command_handler.go Normal file
View File

@ -0,0 +1,42 @@
package main
import (
"log"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
func getCurrentStatus(dataStore *DataStore) string {
return ""
}
func HandleTelegramCommands(bot tgbotapi.BotAPI, logger *log.Logger, dataStore *DataStore) {
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil { // ignore any non-Message updates
continue
}
if !update.Message.IsCommand() { // ignore any non-command Messages
continue
}
// Create a new MessageConfig. We don't have text yet,
// so we leave it empty.
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "")
// Extract the command from the Message.
switch update.Message.Command() {
case "status":
msg.Text = getCurrentStatus(dataStore)
}
if _, err := bot.Send(msg); err != nil {
logger.Print(err)
}
}
}