mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 01:22:48 +00:00
convert to chi web framework - add tls support
This commit is contained in:
@@ -2,15 +2,19 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Variables used for command line parameters
|
||||
var Config configStruct
|
||||
var (
|
||||
Config configFile
|
||||
Flags configFlags
|
||||
)
|
||||
|
||||
type configStruct struct {
|
||||
type configFile struct {
|
||||
Token string `json:"Token"`
|
||||
BotPrefix string `json:"BotPrefix"` //prefix to use for bot commands
|
||||
SoundsPath string `json:"SoundsPath"`
|
||||
@@ -18,8 +22,21 @@ type configStruct struct {
|
||||
ServerAddr string `json:"ServerAddr`
|
||||
}
|
||||
|
||||
type configFlags struct {
|
||||
Prod bool
|
||||
TLS bool
|
||||
}
|
||||
|
||||
// Init -
|
||||
func Init() {
|
||||
|
||||
parseConfig()
|
||||
parseFlags()
|
||||
|
||||
}
|
||||
|
||||
func parseConfig() {
|
||||
|
||||
log.Println("Reading config file...")
|
||||
|
||||
file, e := ioutil.ReadFile("./config.json")
|
||||
@@ -36,5 +53,23 @@ func Init() {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
func parseFlags() {
|
||||
|
||||
Flags.Prod = false
|
||||
Flags.TLS = false
|
||||
|
||||
prod := flag.Bool("p", false, "Run in production")
|
||||
tls := flag.Bool("tls", false, "Use TLS")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
Flags.Prod = *prod
|
||||
Flags.TLS = *tls
|
||||
|
||||
if *prod {
|
||||
log.Println("Running in production mode")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user