-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
34 lines (29 loc) · 806 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
package main
import (
"fmt"
"math/rand"
"os"
"time"
"github.com/khuttun/bluffbot/bluff"
"github.com/khuttun/bluffbot/telegram"
)
func main() {
port := os.Getenv("PORT")
username := os.Getenv("USERNAME")
token := os.Getenv("TELEGRAM_TOKEN")
webhook := os.Getenv("WEBHOOK")
if port == "" || username == "" || token == "" || webhook == "" {
fmt.Println("Expecting following environment variables to be set:")
fmt.Println("PORT")
fmt.Println("USERNAME")
fmt.Println("TELEGRAM_TOKEN")
fmt.Println("WEBHOOK")
os.Exit(1)
}
rand.Seed(time.Now().UTC().UnixNano())
t := telegram.BotAPI{Port: port, TelegramURL: fmt.Sprintf("https://api.telegram.org/bot%v/", token)}
b := bluff.NewBot(username, &t)
t.UpdateHandler = b.HandleUpdate
t.SetWebhook(webhook)
t.StartReceivingUpdates()
}