-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (37 loc) · 809 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
package main
import (
"flag"
"log"
tgClient "paper_adviser_bot/clients/telegram"
"paper_adviser_bot/events/telegram"
"paper_adviser_bot/storage/files"
"paper_adviser_bot/consumer/event_consumer"
)
const(
tgBotHost = "api.telegram.org"
storagePath = "file_storage"
batchSize = 100
)
func main() {
eventsProcessor := telegram.New(
tgClient.New(tgBotHost, mustToken()),
files.New(storagePath),
)
log.Print("service started")
consumer := event_consumer.New(eventsProcessor, eventsProcessor, batchSize)
if err := consumer.Start(); err != nil {
log.Fatal("service is stopped", err)
}
}
func mustToken() string {
token := flag.String(
"tg-bot-token",
"",
"token for tg bot access",
)
flag.Parse()
if *token == "" {
log.Fatal("token is not specified")
}
return *token
}