-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (42 loc) · 904 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
package main
import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/yanzay/tbot/v2"
)
type score struct {
wins, draws, losses uint
}
type application struct {
client *tbot.Client
score
}
var (
app application
bot *tbot.Server
token string
options = map[string]string{
// choice : beats
"paper": "rock",
"rock": "scissors",
"scissors": "paper",
}
)
func init() {
e := godotenv.Load()
if e != nil {
log.Println(e)
}
token = os.Getenv("TELEGRAM_TOKEN")
}
func main() {
bot = tbot.New(token, tbot.WithWebhook("https://rochambeau-bot.herokuapp.com", ":"+os.Getenv("PORT")))
app.client = bot.Client()
bot.HandleMessage("/start", app.startHandler)
bot.HandleMessage("/play", app.playHandler)
bot.HandleMessage("/score", app.scoreHandler)
bot.HandleMessage("/reset", app.resetHandler)
bot.HandleCallback(app.callbackHandler)
log.Fatal(bot.Start())
}