-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
56 lines (45 loc) · 1.2 KB
/
Copy pathmain.go
File metadata and controls
56 lines (45 loc) · 1.2 KB
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
//go:generate go run github.com/AshokShau/gotdbot/scripts/tools
import (
"coolifymanager/src"
"coolifymanager/src/config"
"log"
"strconv"
"time"
_ "time/tzdata"
"github.com/AshokShau/gotdbot"
)
func main() {
if err := config.InitConfig(); err != nil {
panic("failed to init config" + err.Error())
}
loc, err := time.LoadLocation("Asia/Kolkata")
if err != nil {
log.Printf("⚠Failed to load Asia/Kolkata time zone: %v. Using UTC.", err)
} else {
time.Local = loc
}
apiID, err := strconv.Atoi(config.ApiId)
if err != nil {
log.Fatalf("❌ Invalid API_ID: %v", err)
}
tdlibLibraryPath := config.TdlibLibraryPath
if tdlibLibraryPath == "" {
tdlibLibraryPath = "./libtdjson.so.1.8.64"
}
bot, err := gotdbot.NewClient(int32(apiID), config.ApiHash, config.Token, &gotdbot.ClientOpts{
LibraryPath: tdlibLibraryPath,
AutoRetry: &gotdbot.AutoRetry{MaxFloodWait: 5 * time.Minute, ChatNotFound: true},
})
if err != nil {
log.Fatalf("❌ Failed to create bot client: %v", err)
}
err = src.InitFunc(bot)
if err != nil {
panic("failed to initialize bot: " + err.Error())
}
if err = bot.Start(); err != nil {
panic("failed to start bot: " + err.Error())
}
bot.Idle()
}