Initial stub of command support
This commit is contained in:
parent
f2e5684477
commit
cbc3d68c95
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue