diff --git a/command_handler.go b/command_handler.go index 3f5f2d1..08a9264 100644 --- a/command_handler.go +++ b/command_handler.go @@ -1,17 +1,19 @@ package main import ( + "html/template" "log" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) -func getCurrentStatus(dataStore *DataStore, config AppConfig) string { - // elements := FilterBasicElementsByTypeOrIndex(dataStore.GetBasicEventElements(), config.AllowedTypes, config.AllowedIndexes) - return "" +func getCurrentStatus(dataStore *DataStore, logger *log.Logger, config AppConfig, tpl *template.Template, s SatelNameGetter) string { + elements := FilterBasicElementsByTypeOrIndex(dataStore.GetBasicEventElements(), config.AllowedTypes, config.AllowedIndexes) + msg := GenericMessage{elements} + return msg.Format(tpl, s, logger) } -func HandleTelegramCommands(bot tgbotapi.BotAPI, logger *log.Logger, dataStore *DataStore, config AppConfig) { +func HandleTelegramCommands(bot tgbotapi.BotAPI, logger *log.Logger, dataStore *DataStore, config AppConfig, tpl *template.Template, s SatelNameGetter) { u := tgbotapi.NewUpdate(0) u.Timeout = 60 @@ -33,7 +35,7 @@ func HandleTelegramCommands(bot tgbotapi.BotAPI, logger *log.Logger, dataStore * // Extract the command from the Message. switch update.Message.Command() { case "status": - msg.Text = getCurrentStatus(dataStore, config) + msg.Text = getCurrentStatus(dataStore, logger, config, tpl, s) } if _, err := bot.Send(msg); err != nil {