43 lines
893 B
Go
43 lines
893 B
Go
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|