Documentation ¶
Index ¶
- Constants
- Variables
- type Alertmanager
- type Bot
- type BotChatStore
- type BotOption
- func WithAddr(addr string) BotOption
- func WithAlertmanager(alertmanager Alertmanager) BotOption
- func WithCommandEvent(callback func(command string)) BotOption
- func WithExtraAdmins(ids ...int) BotOption
- func WithLogger(l log.Logger) BotOption
- func WithRevision(r string) BotOption
- func WithStartTime(st time.Time) BotOption
- func WithTemplates(alertmanager *url.URL, templatePaths ...string) BotOption
- type ChatStore
- type Telebot
Constants ¶
const ( CommandStart = "/start" CommandStop = "/stop" CommandHelp = "/help" CommandChats = "/chats" CommandID = "/id" CommandStatus = "/status" CommandAlerts = "/alerts" CommandSilences = "/silences" ResponseHelp = ` I'm a Prometheus AlertManager Bot for Telegram. I will notify you about alerts. You can also ask me about my ` + CommandStatus + `, ` + CommandAlerts + ` & ` + CommandSilences + ` Available commands: ` + CommandStart + ` - Subscribe for alerts. ` + CommandStop + ` - Unsubscribe for alerts. ` + CommandStatus + ` - Print the current status. ` + CommandAlerts + ` - List all alerts. ` + CommandSilences + ` - List all silences. ` + CommandChats + ` - List all users and group chats that subscribed. ` + CommandID + ` - Send the senders Telegram ID (works for all Telegram users). ` )
Variables ¶
var ChatNotFoundErr = errors.New("chat not found in store")
ChatNotFoundErr returned by the store if a chat isn't found.
Functions ¶
This section is empty.
Types ¶
type Alertmanager ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot runs the alertmanager telegram.
func NewBotWithTelegram ¶
func (*Bot) Run ¶
func (b *Bot) Run(ctx context.Context, webhooks <-chan alertmanager.TelegramWebhook) error
Run the telegram and listen to messages send to the telegram.
func (*Bot) SendAdminMessage ¶
SendAdminMessage to the admin's ID with a message.
type BotChatStore ¶
type BotChatStore interface { List() ([]*telebot.Chat, error) Get(telebot.ChatID) (*telebot.Chat, error) Add(*telebot.Chat) error Remove(*telebot.Chat) error }
BotChatStore is all the Bot needs to store and read.
type BotOption ¶
BotOption passed to NewBot to change the default instance.
func WithAddr ¶
WithAddr sets the internal listening addr of the bot's web server receiving webhooks.
func WithAlertmanager ¶
func WithAlertmanager(alertmanager Alertmanager) BotOption
func WithCommandEvent ¶
WithCommandEvent sets a func to call whenever commands are handled.
func WithExtraAdmins ¶
WithExtraAdmins allows the specified additional user IDs to issue admin commands to the bot.
func WithLogger ¶
WithLogger sets the logger for the Bot as an option.
func WithRevision ¶
WithRevision is setting the Bot's revision for status commands.
func WithStartTime ¶
WithStartTime is setting the Bot's start time for status commands.
type ChatStore ¶
type ChatStore struct {
// contains filtered or unexported fields
}
ChatStore writes the users to a libkv store backend.
func NewChatStore ¶
NewChatStore stores telegram chats in the provided kv backend.