forked from inCaller/prometheus_bot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd.go
More file actions
43 lines (36 loc) · 1.08 KB
/
cmd.go
File metadata and controls
43 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"gopkg.in/telegram-bot-api.v4"
)
type Bot struct {
telegram *tgbotapi.BotAPI
}
const (
// commandStart = "/start"
// commandStop = "/stop"
commandHelp = "/help"
commandChatsID = "/chat_id"
// commandStatus = "/status"
// commandAlerts = "/alerts"
// commandSilences = "/silences"
// commandSilenceAdd = "/silence_add"
// commandSilence = "/silence"
// commandSilenceDel = "/silence_del"
// responseStart = "Hey, %s! I will now keep you up to date!\n" + commandHelp
// responseStop = "Alright, %s! I won't talk to you again.\n" + commandHelp
responseHelp = `
I'm a Prometheus AlertManager Bot for Telegram. I will notify you about alerts.
Available commands:
` + commandChatsID + ` - Get current chat ID.
` + commandHelp + ` - Get help.
`
)
func (b *Bot) handleHelp(message *tgbotapi.Message) {
msg := tgbotapi.NewMessage(message.Chat.ID, responseHelp)
bot.Send(msg)
}
func (b *Bot) handleChatsID(message *tgbotapi.Message) {
msg := tgbotapi.NewMessage(message.Chat.ID, fmt.Sprintf("Chat id is '%d'", message.Chat.ID))
bot.Send(msg)
}