mirror of
https://github.com/beerpiss/saekawa.git
synced 2024-11-23 23:00:58 +01:00
feat: create a pre-commented config file if possible
This commit is contained in:
parent
30b00c242e
commit
ee849ca846
@ -1,54 +1,36 @@
|
|||||||
[general]
|
[general]
|
||||||
# Set to 'false' to disable the hook
|
# Whether the hook should export class medals (dans) and emblems.
|
||||||
enable = true
|
|
||||||
# Whether the hook should export your class medals and emblems or not.
|
|
||||||
export_class = true
|
export_class = true
|
||||||
# Whether the hook should export PBs. This should be used as a last resort, if
|
|
||||||
# you cannot import scores from your network, since this provides less data
|
# Whether FAILED lamps should override FULL COMBO and ALL JUSTICE.
|
||||||
# and sends only one pre-joined score per chart. Will only work once every session; you'll
|
# Not recommended, but it's an option.
|
||||||
# need to restart the game to do it again.
|
|
||||||
export_pbs = false
|
|
||||||
# Whether FAILED should override FULL COMBO and ALL JUSTICE.
|
|
||||||
fail_over_lamp = false
|
fail_over_lamp = false
|
||||||
# Timeout for web requests, in milliseconds
|
|
||||||
timeout = 30000
|
# Timeout for web requests, in milliseconds. If your network connection
|
||||||
|
# to Tachi is unstable, you might want to bump this up.
|
||||||
|
timeout = 3000
|
||||||
|
|
||||||
|
# Whether the hook should update itself when a new update is found.
|
||||||
|
auto_update = true
|
||||||
|
|
||||||
|
# The directory/folder to store failed imports due to network
|
||||||
|
# connectivity issues. It will not save any imports rejected
|
||||||
|
# by Tachi for other reasons.
|
||||||
|
failed_import_dir = "failed_saekawa_imports"
|
||||||
|
|
||||||
[cards]
|
[cards]
|
||||||
# **DOES NOT WORK FOR WHITELISTING PBS!!**
|
# Tachi API keys go here. You can set a default API key for all
|
||||||
#
|
# cards using the `default` key:
|
||||||
# Access codes that should be whitelisted
|
# default = "example-api-key"
|
||||||
# If this is empty, all cards will be whitelisted
|
# You can also set the API key that will be used for a specific access code
|
||||||
# There should be no whitespace between the digits
|
# (useful for shared setups):
|
||||||
#
|
# "00001111222233334444" = "example-api-key-1"
|
||||||
# example: whitelist = ["00001111222233334444"]
|
# "55556666777788889999" = "example-api-key-2"
|
||||||
whitelist = []
|
# The `default` key can also be removed, discarding any scores
|
||||||
|
# that do not come from the list of access codes configured.
|
||||||
|
|
||||||
[crypto]
|
default = "your-api-key"
|
||||||
# Since CRYSTAL+, the game employs network encryption. If you do not wish to
|
|
||||||
# patch out encryption from your game, you will need to fill in these values.
|
|
||||||
#
|
|
||||||
# All values are in hex strings.
|
|
||||||
key = ""
|
|
||||||
iv = ""
|
|
||||||
|
|
||||||
# Salt for deriving hashed API endpoint names. Not necessary on PARADISE LOST
|
|
||||||
# and older. For CHUNITHM NEW and later versions, this must be set if encryption
|
|
||||||
# is not patched out, otherwise the hook will be active but doing nothing, since
|
|
||||||
# it cannot recognize the score upload endpoint.
|
|
||||||
#
|
|
||||||
# This must also be a hex string.
|
|
||||||
salt = ""
|
|
||||||
|
|
||||||
# Number of PBKDF2 iterations to hash the endpoint URL. Set to 70 for CHUNITHM SUN
|
|
||||||
# and newer, and 44 for older versions.
|
|
||||||
iterations = 70
|
|
||||||
|
|
||||||
[tachi]
|
[tachi]
|
||||||
# Tachi instance base URL
|
# The base URL of the Tachi instance to submit scores to.
|
||||||
base_url = "https://kamai.tachi.ac"
|
base_url = "https://kamai.tachi.ac/"
|
||||||
# Tachi status endpoint
|
|
||||||
status = "/api/v1/status"
|
|
||||||
# Tachi score import endpoint
|
|
||||||
import = "/ir/direct-manual/import"
|
|
||||||
# Your Tachi API key
|
|
||||||
api_key = "your-key-here"
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
mod defaults;
|
mod defaults;
|
||||||
mod migrate;
|
mod migrate;
|
||||||
|
|
||||||
use std::{collections::HashMap, fs::File, path::PathBuf, str::FromStr};
|
use std::{collections::HashMap, fs::File, io::Write, path::{Path, PathBuf}, str::FromStr};
|
||||||
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use migrate::OldSaekawaConfig;
|
use migrate::OldSaekawaConfig;
|
||||||
@ -37,6 +37,13 @@ pub enum MigrationError {
|
|||||||
|
|
||||||
impl SaekawaConfig {
|
impl SaekawaConfig {
|
||||||
pub fn load() -> Result<SaekawaConfig, ConfigLoadError> {
|
pub fn load() -> Result<SaekawaConfig, ConfigLoadError> {
|
||||||
|
if !Path::new("saekawa.toml").exists() {
|
||||||
|
// We don't really care about the error here, since Confy will autogenerate a
|
||||||
|
// default configuration file anyways. That one just doesn't have comments.
|
||||||
|
let _ = File::create_new("saekawa.toml")
|
||||||
|
.and_then(|mut file| file.write_all(include_bytes!("../../res/saekawa.toml")));
|
||||||
|
}
|
||||||
|
|
||||||
let result = confy::load_path::<SaekawaConfig>("saekawa.toml");
|
let result = confy::load_path::<SaekawaConfig>("saekawa.toml");
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
|
Loading…
Reference in New Issue
Block a user