-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (33 loc) · 745 Bytes
/
main.go
File metadata and controls
43 lines (33 loc) · 745 Bytes
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 (
"log"
"os"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal(err)
}
token := os.Getenv("TOKEN")
if token == "" {
log.Fatal("TOKEN is not set in .env file")
}
bot, err := tgbotapi.NewBotAPI(token)
if err != nil {
log.Fatal(err)
}
bot.Debug = true
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 && update.Message.Video != nil {
handleVideo(bot, update)
} else if update.CallbackQuery != nil {
handleCallbackQuery(bot, update, token)
}
}
}