-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (44 loc) · 2.47 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/fatih/color"
telegram "github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/joho/godotenv"
"github.com/BecauseOfProg/BecauseOfProg_Bot/lib"
)
func main() {
fmt.Println(color.HiRedString(" ________ _______ ________ ________ ___ ___ ________ _______ ________ ________ ________ ________ ________ ________ \n|\\ __ \\|\\ ___ \\ |\\ ____\\|\\ __ \\|\\ \\|\\ \\|\\ ____\\|\\ ___ \\ |\\ __ \\|\\ _____\\\\ __ \\|\\ __ \\|\\ __ \\|\\ ____\\ \n\\ \\ \\|\\ /\\ \\ __/|\\ \\ \\___|\\ \\ \\|\\ \\ \\ \\\\\\ \\ \\ \\___|\\ \\ __/|\\ \\ \\|\\ \\ \\ \\__/\\ \\ \\|\\ \\ \\ \\|\\ \\ \\ \\|\\ \\ \\ \\___| \n \\ \\ __ \\ \\ \\_|/_\\ \\ \\ \\ \\ __ \\ \\ \\\\\\ \\ \\_____ \\ \\ \\_|/_\\ \\ \\\\\\ \\ \\ __\\\\ \\ ____\\ \\ _ _\\ \\ \\\\\\ \\ \\ \\ ___ \n \\ \\ \\|\\ \\ \\ \\_|\\ \\ \\ \\____\\ \\ \\ \\ \\ \\ \\\\\\ \\|____|\\ \\ \\ \\_|\\ \\ \\ \\\\\\ \\ \\ \\_| \\ \\ \\___|\\ \\ \\\\ \\\\ \\ \\\\\\ \\ \\ \\|\\ \\ \n \\ \\_______\\ \\_______\\ \\_______\\ \\__\\ \\__\\ \\_______\\____\\_\\ \\ \\_______\\ \\_______\\ \\__\\ \\ \\__\\ \\ \\__\\\\ _\\\\ \\_______\\ \\_______\\\n \\|_______|\\|_______|\\|_______|\\|__|\\|__|\\|_______|\\_________\\|_______|\\|_______|\\|__| \\|__| \\|__|\\|__|\\|_______|\\|_______|\n \\|_________| "))
if err := godotenv.Load(); err != nil {
log.Println("💾 No .env file at the root - Ignoring")
}
bot, err := telegram.NewBotAPI(os.Getenv("TELEGRAM_APITOKEN"))
if err != nil {
log.Println(lib.Red.Sprintf("‼ Error creating Telegram bot: %s", err))
return
}
if os.Getenv("BOT_ENV") == "development" {
bot.Debug = true
}
log.Println(lib.Green.Sprintf("✅ Authorized on account %s", bot.Self.UserName))
u := telegram.NewUpdate(0)
u.Timeout = 60
updates, _ := bot.GetUpdatesChan(u)
for update := range updates {
var err error
if update.InlineQuery != nil {
err = HandleInlineQuery(bot, update)
} else if update.CallbackQuery != nil {
if strings.HasPrefix(update.CallbackQuery.Data, "/") {
err = HandleCommand(bot, update, true)
}
} else if update.Message.IsCommand() {
err = HandleCommand(bot, update, false)
}
if err != nil {
log.Println(lib.Red.Sprintf("‼ Error handling an event: %s", err))
}
}
}