-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (35 loc) · 820 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
package main
import (
"fmt"
"os"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/joho/godotenv"
"github.com/xmayukx/straw/cmd"
)
func main() {
err := godotenv.Load()
if err != nil {
panic(err)
}
bot, err := tgbotapi.NewBotAPI(os.Getenv("TGBOTAPIKEY"))
if err != nil {
panic(err)
}
bot.Debug = false
fmt.Print(bot.GetMe())
cmd.BotInstance(bot)
updateConfig := tgbotapi.NewUpdate(0)
updateConfig.Timeout = 20
msgQueue := make(chan tgbotapi.MessageConfig)
go cmd.ProcessMsg(&msgQueue)
updates := bot.GetUpdatesChan(updateConfig)
for update := range updates {
if update.Message == nil {
continue
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "")
msg.ReplyToMessageID = update.Message.MessageID
cmd.UpdateInstance(&update)
msgQueue <- msg
}
}