diff options
author | Joe Rayhawk <jrayhawk+git@omgwallhack.org> | 2023-12-27 12:21:38 -0800 |
---|---|---|
committer | Joe Rayhawk <jrayhawk+git@omgwallhack.org> | 2023-12-27 12:33:49 -0800 |
commit | 11b8b62fd544479c07f34c57aedd807de53308c4 (patch) | |
tree | 3a20b3d0a1e659bd8f192cd143c1a15bad4b3896 /crystal/lib/bungmobott | |
parent | 0438391b4ec94404582b71b0fb4e12bc999c0021 (diff) | |
download | twitchtools-11b8b62fd544479c07f34c57aedd807de53308c4.tar.gz twitchtools-11b8b62fd544479c07f34c57aedd807de53308c4.zip |
crystal bungmobott: add YAML::Serializable configuration management system as module
Diffstat (limited to 'crystal/lib/bungmobott')
-rw-r--r-- | crystal/lib/bungmobott/src/bungmobott.cr | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/crystal/lib/bungmobott/src/bungmobott.cr b/crystal/lib/bungmobott/src/bungmobott.cr new file mode 100644 index 0000000..d54eaad --- /dev/null +++ b/crystal/lib/bungmobott/src/bungmobott.cr @@ -0,0 +1,71 @@ +#--- +#statedir: /home/jrayhawk/.local/state/bungmobott/ +#tempdir: /tmp/bungmobott/ +#listen: 0.0.0.0:5555 +#join_channels: +# twitch: +# - bungmonkey +# - dopefish +# # - yackamov +# gamesurge: +# - bungmonkey +#twitch_user_id: 59895482 # saves a lookup +#chat_user: +# twitch: bungmonkey +# gamesurge: bungmoBott + +module BungmoBott + + EXE = "bungmobott" + + class ChatUser + include YAML::Serializable + include YAML::Serializable::Unmapped + property twitch : String? + property gamesurge : String? + end + + class JoinChannels + include YAML::Serializable + include YAML::Serializable::Unmapped + property twitch : Array(String)? + property gamesurge : Array(String)? + end + + class Config + include YAML::Serializable + include YAML::Serializable::Unmapped + 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 = ( + ENV["TEMP"]? && ENV["TEMP"] + "\\#{EXE}\\" || + "/tmp/#{EXE}/" + ) + property rundir : String = ( + ENV["XDG_RUNTIME_DIR"]? && ENV["XDG_RUNTIME_DIR"] + "/#{EXE}/" || + "/tmp/#{EXE}/" + ) # FIXME: do sockets and such even work on Windows? + # Should probably warn about that somewhere around here. + #@[YAML::Field(emit_null: true)] + property listen : String? = nil + property chat_user : ChatUser? = ChatUser.from_yaml("---") + property join_channels : JoinChannels? = JoinChannels.from_yaml("---") + property twitch_user_id : UInt32? = nil + end + class Secrets + include YAML::Serializable + include YAML::Serializable::Unmapped + @[YAML::Field(emit_null: true)] + property twitch_access_token : String? + @[YAML::Field(emit_null: true)] + property twitch_client_id : String? + @[YAML::Field(emit_null: true)] + property gcloud_token : String? + @[YAML::Field(emit_null: true)] + property gamesurge_password : String? + end +end + |