Browse Source

config go files cleanup

cleanup the config golang files.
main
Michael Parker 1 year ago
parent
commit
abf75a60d3
  1. 12
      config.go
  2. 24
      config_examples.go

12
config.go

@ -188,7 +188,9 @@ func loadNWatch(file confFile) {
switch event.Op {
case fsnotify.Write:
Log.Infof("file changed: %s", event.Name)
loadConf(file)
if err := loadConf(file); err != nil {
Log.Errorf("%+v", err)
}
}
case err := <-watcher.Errors:
Log.Errorf("%+v", err)
@ -473,7 +475,9 @@ func loadInitConfig(confDir, conf, verbose string) (botConfig parkertron, err er
if err = createIfDoesntExist(confDir + conf); err != nil {
if verbose == "debug" {
log.Printf("creating config %s", confDir+conf)
createExampleBotConfig(confDir, conf, verbose)
if err := createExampleBotConfig(confDir, conf, verbose); err != nil {
return parkertron{}, err
}
}
}
@ -489,7 +493,9 @@ func loadInitConfig(confDir, conf, verbose string) (botConfig parkertron, err er
}
if file.Size() == 0 {
createExampleBotConfig(confDir, conf, verbose)
if err := createExampleBotConfig(confDir, conf, verbose); err != nil {
return parkertron{}, err
}
}
if strings.HasSuffix(conf, "yaml") || strings.HasSuffix(conf, "yml") {

24
config_examples.go

@ -24,7 +24,9 @@ func createExampleBotConfig(confDir, conf, verbose string) (err error) {
if err != nil {
return
}
fileCheck.Close()
if err := fileCheck.Close(); err != nil {
return err
}
file, err := os.Stat(confDir + conf)
if err != nil {
@ -63,7 +65,7 @@ func createExampleBotConfig(confDir, conf, verbose string) (err error) {
return
}
func createExampleDiscordConfig(confDir, verbose string) (err error) {
func createExampleDiscordConfig(confDir string) (err error) {
// if the config dir doesn't exist make it
Log.Debugf("creating example config folder %s if it doesn't exist", confDir)
if err = createIfDoesntExist(confDir); err != nil {
@ -114,7 +116,7 @@ func createExampleDiscordConfig(confDir, verbose string) (err error) {
Clear: true,
},
ChanGroups: []channelGroup{
channelGroup{
{
ChannelIDs: []string{
"a-channel-id",
"another-channel-id",
@ -130,13 +132,13 @@ func createExampleDiscordConfig(confDir, verbose string) (err error) {
},
},
Commands: []command{
command{
{
Command: "example",
Response: []string{"This is the response to the &prefix&example command"},
},
},
Keywords: []keyword{
keyword{
{
Keyword: "example",
Reaction: []string{""},
Response: []string{"I have responded to seeing the word example."},
@ -168,7 +170,7 @@ func createExampleDiscordConfig(confDir, verbose string) (err error) {
},
},
Permissions: []permission{
permission{
{
Group: "admin",
Users: []string{},
Roles: []string{},
@ -193,7 +195,7 @@ func createExampleDiscordConfig(confDir, verbose string) (err error) {
return
}
func createExampleIRCConfig(confDir, verbose string) (err error) {
func createExampleIRCConfig(confDir string) (err error) {
// if the config dir doesn't exist make it
Log.Debugf("creating example config folder %s if it doesn't exist", confDir)
if err = createIfDoesntExist(confDir); err != nil {
@ -229,7 +231,7 @@ func createExampleIRCConfig(confDir, verbose string) (err error) {
Prefix: ".",
},
ChanGroups: []channelGroup{
channelGroup{
{
ChannelIDs: []string{
"a-channel-name",
"another-channel-name",
@ -243,14 +245,14 @@ func createExampleIRCConfig(confDir, verbose string) (err error) {
},
},
Commands: []command{
command{
{
Command: "example",
Reaction: []string{""},
Response: []string{"This is the response to the &prefix&example command"},
},
},
Keywords: []keyword{
keyword{
{
Keyword: "example",
Response: []string{"I have responded to seeing the word example."},
},
@ -265,7 +267,7 @@ func createExampleIRCConfig(confDir, verbose string) (err error) {
},
},
Permissions: []permission{
permission{
{
Group: "admin",
Users: []string{},
Roles: []string{},

Loading…
Cancel
Save