-
Notifications
You must be signed in to change notification settings - Fork 0
/
srakabot.go
52 lines (39 loc) · 908 Bytes
/
srakabot.go
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
44
45
46
47
48
49
50
51
52
package main
import (
"flag"
"log"
"os"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
var appConfig *Config
var AllowedCommands = []string{
"/stats",
"/showRanksTest",
"/rankDiag",
"/bledina",
}
func main() {
var err error
configFileLocationPtr := flag.String("config", os.Getenv("HOME")+"/.srakabot.yml", "Config file location")
appConfig, err = getConfig(*configFileLocationPtr)
if err != nil {
log.Fatalf("Could not load configuration")
}
//connect to touchbase
cbConnect()
if !sraketa_init() {
log.Printf("Could not initialize alerts")
}
bot, err := tgbotapi.NewBotAPI(appConfig.Telegram.ApiToken)
if err != nil {
os.Exit(1)
}
bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates := bot.GetUpdatesChan(u)
for update := range updates {
processUpdate(bot, update)
}
}