Skip to content
Extraits de code Groupes Projets
Vérifiée Valider b34bca16 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Correct default ini file config

parent 548610df
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
[user]
id = "@some_id:matrix.org"
password = no-password
display_name = MGB-Hitagi
[handler]
state_member = true
[basic]
name = basic package
acl = any
admins = @martin2018:iiens.net
[user]
id=@some_id\:matrix.org
password=no-password
display_name=MGB-Hitagi
[handler]
state_member=true
room_message=true
......@@ -12,7 +12,6 @@ pub struct Config {
pub user_password: String, // The true user name
pub handle_state_member: bool, // Install handler for state memver changes
pub handle_room_message: bool, // Install handler for room messages
ini_handler: Ini,
}
......@@ -47,9 +46,6 @@ pub fn from_file(file_name: &String) -> Result<Config, String> {
Err(IniErrParse(e)) => Err(e.to_string()),
Ok(conf) => {
let hs_url_str = conf.get_from_or(Some("user"), "homeserver", "https://matrix.org");
let handle_room_message_str = conf
.get_from_or(Some("handler"), "room_message", "true")
.to_string();
let handle_state_member_str = conf
.get_from_or(Some("handler"), "state_member", "true")
.to_string();
......@@ -66,8 +62,6 @@ pub fn from_file(file_name: &String) -> Result<Config, String> {
.get_from_or(Some("user"), "display_name", "MGB-Hitagi")
.to_string(),
homeserver_url: hs_url,
handle_room_message: <bool as FromStr>::from_str(&handle_room_message_str)
.unwrap_or(false),
handle_state_member: <bool as FromStr>::from_str(&handle_state_member_str)
.unwrap_or(false),
ini_handler: conf,
......@@ -84,8 +78,11 @@ pub fn write_default(file_name: &String) -> Result<(), String> {
.set("password", "no-password")
.set("display_name", "MGB-Hitagi");
conf.with_section(Some("handler"))
.set("state_member", "true")
.set("room_message", "true");
.set("state_member", "true");
conf.with_section(Some("basic"))
.set("name", "basic package")
.set("acl", "any")
.set("admins", "@some_id:matrix.org");
match conf.write_to_file_policy(file_name, ini::EscapePolicy::Everything) {
Ok(()) => {
info!("Default config file written to {}", file_name);
......@@ -104,7 +101,7 @@ pub fn check_argument_or_abort(should_write_default: bool) {
.last()
.unwrap()
.to_string()
+ ".yml";
+ ".ini";
if Path::new(&default_file).exists() {
error!(
"Args count is {}, you need to only specify the config file for the bot",
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter