dorisbot/main.go

56 lines
754 B
Go
Raw Normal View History

2019-06-28 09:37:37 +00:00
package main
import (
2019-06-30 15:05:54 +00:00
"dorisbot/models"
2019-06-30 10:12:00 +00:00
"dorisbot/pkg/config"
2019-06-28 09:37:37 +00:00
"dorisbot/pkg/options"
"dorisbot/pkg/svc/discord"
"fmt"
"log"
)
func init() {
options.RegOptions()
}
func main() {
2019-06-30 10:12:00 +00:00
var err error
2019-06-28 09:37:37 +00:00
opts := options.GetOptions()
if opts.Help {
opts.ShowUsage()
return
}
fmt.Println("Bot Svc")
cc := make(chan bool)
2019-06-30 10:12:00 +00:00
err = config.LoadConfig(opts.Config)
if err != nil {
log.Fatal(err)
}
conf := config.GetConfig()
2019-07-02 09:02:31 +00:00
_, err = models.NewDB(conf.Database)
2019-06-28 09:37:37 +00:00
if err != nil {
log.Fatal(err)
}
2019-07-02 09:02:31 +00:00
err = models.Ping()
2019-06-28 09:37:37 +00:00
if err != nil {
log.Fatal(err)
}
2019-07-02 09:02:31 +00:00
client, err := discord.NewClient(conf.Discord.BotToken)
2019-06-30 15:05:54 +00:00
if err != nil {
log.Fatal(err)
}
2019-07-02 09:02:31 +00:00
err = client.Connect()
2019-06-30 15:05:54 +00:00
if err != nil {
log.Fatal(err)
}
2019-07-02 09:02:31 +00:00
defer client.Close()
2019-06-30 15:05:54 +00:00
2019-06-28 09:37:37 +00:00
<-cc
}