From 378924fc4f60dbc09c6eac744b1e8e68ecd488ea Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Mon, 26 Feb 2024 19:20:47 -0800 Subject: crystal/lib/bungmobott: define useful default config.voice_list --- crystal/lib/bungmobott/src/bungmobott.cr | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crystal/lib/bungmobott') diff --git a/crystal/lib/bungmobott/src/bungmobott.cr b/crystal/lib/bungmobott/src/bungmobott.cr index 3df034f..0fdb8cc 100644 --- a/crystal/lib/bungmobott/src/bungmobott.cr +++ b/crystal/lib/bungmobott/src/bungmobott.cr @@ -57,16 +57,16 @@ module BungmoBott class Config include YAML::Serializable include YAML::Serializable::Unmapped - property statedir : String = ( + property statedir : String = ( ENV["LOCALAPPDATA"]? && Path.windows( ENV["LOCALAPPDATA"] + "\\#{EXE}\\state\\" ).to_s || ENV["XDG_STATE_HOME"]? && ENV["XDG_STATE_HOME"] + "/#{EXE}/" || Path.home./(".local/state/#{EXE}").to_s ) - property tempdir : String = ( + property tempdir : String = ( ENV["TEMP"]? && ENV["TEMP"] + "\\#{EXE}\\" || "/tmp/#{EXE}/" ) - property rundir : String = ( + property rundir : String = ( ENV["XDG_RUNTIME_DIR"]? && ENV["XDG_RUNTIME_DIR"] + "/#{EXE}/" || "/tmp/#{EXE}/" ) # FIXME: do sockets and such even work on Windows? @@ -87,12 +87,13 @@ module BungmoBott @[YAML::Field(emit_null: true)] property voice_list : String? = nil -# def after_initialize() -# if @voice_list? -# # @voice_list = @statedir + "/voices.txt" -# end -# end + def after_initialize() + if @voice_list.is_a?( Nil ) + @voice_list = Path.new( @statedir, "voices.txt" ).normalize.to_s + end + end end + class Secrets include YAML::Serializable include YAML::Serializable::Unmapped -- cgit v1.2.3