4GKYK7JDUKAOG2D2EXGNV2SMRGL3FOTG3ADLKQKM6476GATQ4BAAC
pub fn new(software: SNS, instance_url: String, token: String) -> Self {
Config {
pub fn new(
software_name: String,
instance_url: String,
token: String,
) -> Result<Config, String> {
let software = match software_name.to_lowercase().as_str() {
"pleroma" => SNS::Pleroma,
"mastodon" => {
eprintln!("* Software other than Pleroma is not tested!");
SNS::Mastodon
}
"firefish" => {
eprintln!("* Software other than Pleroma is not tested!");
SNS::Firefish
}
"friendica" => {
eprintln!("* Software other than Pleroma is not tested!");
SNS::Friendica
}
unsupported => {
return Err(format!("* Software {} is unknown!", unsupported));
}
};
if token.is_empty() {
eprintln!("* ACCESS_TOKEN is not set. Generating...");
let _ = crate::streamer::oath(software, instance_url.as_str());
return Err(String::new());
}
Ok(Config {
pub fn new(logger_type: String, logger_url: Option<String>) -> Self {
pub fn new(logger_name: String, logger_url: Option<String>) -> Logger {
let logger_type = match logger_name.to_lowercase().as_str() {
"stdout" => LoggerType::Stdout,
"discord" => LoggerType::Discord,
_ => {
eprintln!("* LOGGER is not set. Falling back to stdout.");
LoggerType::Stdout
}
};
}
Ok(software) => match software.to_lowercase().as_str() {
"pleroma" => SNS::Pleroma,
"mastodon" => {
eprintln!("* Software other than Pleroma is not tested!");
SNS::Mastodon
}
"firefish" => {
eprintln!("* Software other than Pleroma is not tested!");
SNS::Firefish
}
"friendica" => {
eprintln!("* Software other than Pleroma is not tested!");
SNS::Friendica
}
unsupported => {
return Err(format!("* Software {} is unknown!", unsupported));
}
},
};
let Ok(token) = dotenvy::var("ACCESS_TOKEN") else {
eprintln!("* ACCESS_TOKEN is not set. Generating...");
crate::streamer::oath(software, instance_url.as_str()).await;
return Err(String::new());
};
let logging_method = match dotenvy::var("LOGGER") {
Ok(l) => l,
Err(_) => {
eprintln!("* LOGGER is not set. Falling back to stdout.");
"stdout".to_string()
}