42 lines
735 B
Go
42 lines
735 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"sebclem/claptrapbot-go/config"
|
||
|
"sebclem/claptrapbot-go/discord"
|
||
|
"sebclem/claptrapbot-go/models"
|
||
|
"time"
|
||
|
|
||
|
ginzap "github.com/gin-contrib/zap"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
Token string
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
|
||
|
flag.StringVar(&Token, "t", "", "Bot Token")
|
||
|
flag.Parse()
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
appConf := config.LoadEnv()
|
||
|
config.InitLogger()
|
||
|
|
||
|
db := config.InitDB(appConf)
|
||
|
models.Init(db)
|
||
|
discord.NewDiscord(appConf.DiscordToken, db)
|
||
|
|
||
|
r := gin.Default()
|
||
|
r.Use(ginzap.Ginzap(config.Logger, time.RFC3339, true))
|
||
|
r.Use(ginzap.RecoveryWithZap(config.Logger, true))
|
||
|
r.GET("/ping", func(c *gin.Context) {
|
||
|
c.JSON(200, gin.H{
|
||
|
"message": "pong",
|
||
|
})
|
||
|
})
|
||
|
r.Run() // listen and serve on 0.0.0.0:8080
|
||
|
}
|