forked from BlackPeter13/LightningTipBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (33 loc) · 906 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
package main
import (
"runtime/debug"
"github.com/LightningTipBot/LightningTipBot/internal/lnbits/webhook"
"github.com/LightningTipBot/LightningTipBot/internal/lnurl"
"github.com/LightningTipBot/LightningTipBot/internal/price"
"github.com/LightningTipBot/LightningTipBot/internal/telegram"
log "github.com/sirupsen/logrus"
)
// setLogger will initialize the log format
func setLogger() {
log.SetLevel(log.InfoLevel)
customFormatter := new(log.TextFormatter)
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
customFormatter.FullTimestamp = true
log.SetFormatter(customFormatter)
}
func main() {
// set logger
setLogger()
defer withRecovery()
bot := telegram.NewBot()
webhook.NewServer(&bot)
lnurl.NewServer(&bot)
price.NewPriceWatcher().Start()
bot.Start()
}
func withRecovery() {
if r := recover(); r != nil {
log.Errorln("Recovered panic: ", r)
debug.PrintStack()
}
}