-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
53 lines (39 loc) · 985 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
45
46
47
48
49
50
51
52
53
package main
import (
"log"
"os"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
func main() {
token := os.Getenv("TOKEN")
bot, err := tgbotapi.NewBotAPI(token)
CheckError(err)
bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil {
continue
}
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
if update.Message.IsCommand() {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "")
msg.ParseMode = "html"
switch update.Message.Command() {
case "readme":
msg.Text = ReadTextFile("./Messages/readme.html")
case "emails":
msg.Text = ReadTextFile("./Messages/emails.html")
case "grupos":
msg.Text = ReadTextFile("./Messages/groups.html")
default:
msg.Text = ""
}
if len(msg.Text) > 0 {
bot.Send(msg)
}
}
}
}