1
0
Fork 0

Filtering for status command

This commit is contained in:
Michał Rudowicz 2025-01-12 11:06:13 +01:00
parent 732d173d0d
commit e385a72841
1 changed files with 7 additions and 5 deletions

View File

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