-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (33 loc) · 898 Bytes
/
main.go
File metadata and controls
46 lines (33 loc) · 898 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
44
45
46
package main
import (
"log"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/sliverwing/BusBot/models"
"github.com/sliverwing/BusBot/utils"
)
func main() {
models.User = &models.UserStatus{}
models.CachedLine = &models.CachedLineStruct{}
models.CachedLine.Init()
bot, err := tgbotapi.NewBotAPI("431548070:AAGEgvuPzkqJC-SlV96rUPGpWR4fTtd7XB0")
if err != nil {
log.Panicln(err)
}
bot.Debug = true
log.Printf("Authorized Bot Name: %s\n", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil {
continue
}
if update.Message.IsCommand() {
bot.Send(utils.CommandHandler(update.Message))
continue
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
}
}