-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (29 loc) · 776 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
package main
import (
"io/ioutil"
"log"
"os"
"github.com/shvgn/work-schedule-bot/bot"
"github.com/shvgn/work-schedule-bot/spreadsheet"
"github.com/shvgn/work-schedule-bot/table"
)
func main() {
spreadsheetID, ok := os.LookupEnv("SPREADSHEET_ID")
if !ok {
log.Fatal("SPREADSHEET_ID is not provided in env")
}
client, err := spreadsheet.NewClient("secrets/credentials.json", spreadsheetID)
if err != nil {
log.Fatalf("cannot access spreadsheet: %v", err)
}
tbl := table.NewTable(client)
token, err := ioutil.ReadFile("secrets/telegram_token")
if err != nil {
log.Fatalf("unable to read telegram token file: %v", err)
}
b, err := bot.InitBot(string(token), tbl)
if err != nil {
log.Fatalf("unable to init telegram bot: %v", err)
}
b.Start()
}