-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (30 loc) · 746 Bytes
/
main.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
package main
import (
"log"
"github.com/alexivanenko/my_simple_reminder_bot/cmd"
"github.com/alexivanenko/my_simple_reminder_bot/config"
"github.com/alexivanenko/my_simple_reminder_bot/model"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
func main() {
defer model.GetSession().Close()
bot, err := tgbotapi.NewBotAPI(config.String("bot", "token"))
if err != nil {
log.Panic(err)
}
if config.Is("bot", "debug") {
bot.Debug = true
} else {
bot.Debug = false
}
log.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil {
continue
}
cmd.Run(bot, update.Message)
}
}