package bot
import (
"fmt"
"strconv"
"strings"
"github.com/tiennm99/openai-status-bot/internal/mongostore"
)
func formatInfo(sub mongostore.Subscriber, subscribed bool) string {
chatID := strconv.FormatInt(sub.ChatID, 10)
if sub.ThreadID != nil {
chatID = fmt.Sprintf("%s:%d", chatID, *sub.ThreadID)
}
if !subscribed {
return fmt.Sprintf("Chat Info\n\nChat ID: %s\n\nNot subscribed. Use /start to subscribe.", escape(chatID))
}
components := "all"
if len(sub.Components) > 0 {
components = strings.Join(sub.Components, ", ")
}
return fmt.Sprintf(
"Chat Info\n\nChat ID: %s\n\nTypes: %s\nComponents: %s",
escape(chatID),
escape(strings.Join(sub.Types, ", ")),
escape(components),
)
}
func formatSubscribeUsage(sub mongostore.Subscriber, subscribed bool) string {
current := "none (use /start first)"
components := "all"
if subscribed {
current = strings.Join(sub.Types, ", ")
if len(sub.Components) > 0 {
components = strings.Join(sub.Components, ", ")
}
}
return fmt.Sprintf(
"Usage: /subscribe <type> [component]\n\nTypes: incident, component, all\nComponent filter: /subscribe component api\nClear filter: /subscribe component all\n\nCurrent types: %s\nComponents: %s",
escape(current),
escape(components),
)
}