-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (41 loc) · 1.01 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
package main
import (
"log"
"os"
"time"
"github.com/PaulSonOfLars/gotgbot/v2"
"github.com/PaulSonOfLars/gotgbot/v2/ext"
)
func main() {
token := os.Getenv("TOKEN")
if token == "" {
token = "111:3333kkkk"
}
b, err := gotgbot.NewBot(token, nil)
if err != nil {
log.Fatalln(err.Error())
}
dispatcher := ext.NewDispatcher(&ext.DispatcherOpts{
Error: func(b *gotgbot.Bot, ctx *ext.Context, err error) ext.DispatcherAction {
log.Println("an error occurred while handling update:", err.Error())
return ext.DispatcherActionNoop
},
MaxRoutines: -1,
})
updater := ext.NewUpdater(dispatcher, nil)
if err = updater.StartPolling(b, &ext.PollingOpts{
DropPendingUpdates: false,
EnableWebhookDeletion: true,
GetUpdatesOpts: &gotgbot.GetUpdatesOpts{
AllowedUpdates: []string{"message"},
Timeout: 5,
RequestOpts: &gotgbot.RequestOpts{
Timeout: time.Second * 5,
},
},
}); err != nil {
log.Fatalln(err.Error())
}
log.Println(b.User.FirstName, " has been started!")
updater.Idle()
}