diff --git a/README.md b/README.md index c28bf78..d800463 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Clients (hopefully bots) that disregard `robots.txt` and connect to your instanc HellPot will send an infinite stream of data that is *just close enough* to being a real website that they might just stick around until their soul is ripped apart and they cease to exist. -Under the hood of this eternal suffering is a markov engine that chucks bits and pieces of [The Birth of Tragedy (Hellenism and Pessimism)](https://www.gutenberg.org/files/51356/51356-h/51356-h.htm) by Friedrich Nietzsche at the client using [fasthttp](https://github.com/valyala/fasthttp), or optionally your (least?) favorite text using the `-b`/`--book` flag. +Under the hood of this eternal suffering is a markov engine that chucks bits and pieces of [The Birth of Tragedy (Hellenism and Pessimism)](https://www.gutenberg.org/files/51356/51356-h/51356-h.htm) by Friedrich Nietzsche at the client using [fasthttp](https://github.com/valyala/fasthttp), or optionally you may synchronize HellPot with your nightmares by using the `-g`/`--grimoire` flag ## Building From Source diff --git a/cmd/HellPot/HellPot.go b/cmd/HellPot/HellPot.go index c360b37..597d0d9 100644 --- a/cmd/HellPot/HellPot.go +++ b/cmd/HellPot/HellPot.go @@ -38,7 +38,7 @@ func init() { extra.Banner() - log.Info().Str("caller", "config").Str("file", config.ConfigFilename).Msg(config.ConfigFilename) + log.Info().Str("caller", "config").Str("file", config.Filename).Msg(config.Filename) log.Info().Str("caller", "logger").Msg(config.CurrentLogFile) log.Debug().Str("caller", "logger").Msg("debug enabled") log.Trace().Str("caller", "logger").Msg("trace enabled") diff --git a/internal/config/arguments.go b/internal/config/arguments.go index 7ac340c..d23e05e 100644 --- a/internal/config/arguments.go +++ b/internal/config/arguments.go @@ -30,12 +30,12 @@ func argParse() { os.Exit(1) } loadCustomConfig(os.Args[i+1]) - case "-b", "--book": + case "-g", "--grimoire": if len(os.Args) < i+2 { - println("missing book file after -b/--book") + println("missing source of suffering file after -g/--grimoire") os.Exit(1) } - BookFilename = os.Args[i+1] + Grimoire = os.Args[i+1] UseCustomHeffalump = true default: continue diff --git a/internal/config/config.go b/internal/config/config.go index d5c20b2..7ea53f1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -29,12 +29,12 @@ var ( Trace bool // Debug is the value of our debug (verbose) on/off toggle as per the current configuration. Debug bool - // ConfigFilename returns the current location of our toml config file. - ConfigFilename string + // Filename returns the current location of our toml config file. + Filename string // UseCustomHeffalump decides if a custom Heffalump is to be used UseCustomHeffalump = false - // BookFilename returns the current location of a possible book file - BookFilename string + // Grimoire returns the current location of a possible source of suffering file + Grimoire string ) func writeConfig() { @@ -44,9 +44,9 @@ func writeConfig() { os.Exit(1) } } - ConfigFilename = prefConfigLocation + "/" + "config.toml" - if err := snek.SafeWriteConfigAs(ConfigFilename); err != nil { - fmt.Println("Failed to write new configuration file to '" + ConfigFilename + "': " + err.Error()) + Filename = prefConfigLocation + "/" + "config.toml" + if err := snek.SafeWriteConfigAs(Filename); err != nil { + fmt.Println("Failed to write new configuration file to '" + Filename + "': " + err.Error()) os.Exit(1) } } @@ -75,8 +75,8 @@ func Init() { writeConfig() } - if len(ConfigFilename) < 1 { - ConfigFilename = snek.ConfigFileUsed() + if len(Filename) < 1 { + Filename = snek.ConfigFileUsed() } snek.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_")) @@ -106,9 +106,9 @@ func loadCustomConfig(path string) { os.Exit(1) } - ConfigFilename, err = filepath.Abs(path) - if len(ConfigFilename) < 1 || err != nil { - ConfigFilename = path + Filename, err = filepath.Abs(path) + if len(Filename) < 1 || err != nil { + Filename = path } defer func(f *os.File) { diff --git a/internal/config/defaults.go b/internal/config/defaults.go index f6575fb..0f1ec14 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -86,7 +86,7 @@ func gen(memfs afero.Fs) { println(err.Error()) os.Exit(1) } - print("default configuration successfully written to " + target) + println("default configuration successfully written to " + target) os.Exit(0) } diff --git a/internal/config/help.go b/internal/config/help.go index 30b2d84..f5e8d37 100644 --- a/internal/config/help.go +++ b/internal/config/help.go @@ -22,8 +22,8 @@ var CLI = help{ 1: {0: "--nocolor", 1: "disable color and banner"}, 2: {0: "--banner", 1: "show banner + version and exit"}, 3: {0: "--genconfig", 1: "write default config to " + Title + ".toml then exit"}, - 4: {0: "-b, --book", 1: "", 2: "Specify a custom file used for text generation"}, - 5: {0: "-h, --help", 1: "show this help and exit"}, + 4: {0: "-g, --grimoire", 1: "", 2: "Specify a custom file used for text generation"}, + 5: {0: "-h,--help", 1: "show this help and exit"}, }, out: os.Stdout, } diff --git a/internal/http/router.go b/internal/http/router.go index bd597a6..18842c2 100644 --- a/internal/http/router.go +++ b/internal/http/router.go @@ -124,22 +124,23 @@ func getSrv(r *router.Router) fasthttp.Server { func Serve() error { log = config.GetLogger() - if config.UseCustomHeffalump { - content, err := os.ReadFile(config.BookFilename) + switch config.UseCustomHeffalump { + case true: + content, err := os.ReadFile(config.Grimoire) if err != nil { panic(err) } // Wasteful, but only done once at startup src := string(content) - log.Info().Msgf("Using custom book file '%s'", config.BookFilename) + log.Info().Msgf("Using custom grimoire file '%s'", config.Grimoire) if len(src) < 1 { - panic("book file was empty!") + panic("grimoire file was empty!") } markovMap := heffalump.MakeMarkovMap(strings.NewReader(src)) hellpotHeffalump = heffalump.NewHeffalump(markovMap, heffalump.DefaultBuffSize) - } else { + default: log.Info().Msg("Using default source text") hellpotHeffalump = heffalump.NewDefaultHeffalump() }