-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (35 loc) · 862 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
42
43
44
45
package main
import (
"log"
"os"
handler "tictactoe/api"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/joho/godotenv"
)
func main() {
godotenv.Load()
botToken := os.Getenv("BOT_TOKEN")
if botToken == "" {
log.Fatal("Bot Token env must be set")
}
bot, err := tgbotapi.NewBotAPI(botToken)
if err != nil {
log.Fatal(err)
}
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
if err != nil {
log.Fatal(err)
}
log.Println("Bot is now running. Press Ctrl+C to exit.")
for update := range updates {
if update.Message != nil {
handler.HandleTextMessage(bot, update.Message)
} else if update.CallbackQuery != nil {
handler.HandleCallbackQuery(bot, update.CallbackQuery)
} else if update.InlineQuery != nil {
handler.HandleInlineQuery(bot, update.InlineQuery)
}
}
}