-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
49 lines (36 loc) · 858 Bytes
/
server.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 (
"google.golang.org/grpc"
"github.com/lightningnetwork/lnd/lnrpc"
"LightningTipBot/lnd"
"gopkg.in/tucnak/telebot.v2"
"time"
"LightningTipBot/config"
"log"
"LightningTipBot/telegram"
"LightningTipBot/models"
"LightningTipBot/controllers"
)
func main() {
config.CheckFlags()
err := models.InitDB()
if err != nil {
log.Fatalf("Got error when connect database, the error is '%v'", err)
}
defer models.DB.Close()
var conn *grpc.ClientConn
conn = lnd.Connect(conn)
defer conn.Close()
lnd.Client = lnrpc.NewLightningClient(conn)
bot, err := telebot.NewBot(telebot.Settings{
Token: config.Token,
Poller: &telebot.LongPoller{Timeout: 10 * time.Second},
})
if err != nil {
config.Fatal(err)
}
telegram.InitCommands(bot)
go controllers.InvoiceSettler()
log.Println("Server started..")
bot.Start()
}