From b34bca16b0ad85c06ee879f10608d563344213ba Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 14 Dec 2021 23:39:15 +0100
Subject: [PATCH] Correct default ini file config

---
 mgb.ini       | 12 ++++++++++++
 mgb.yml       |  8 --------
 src/config.rs | 15 ++++++---------
 3 files changed, 18 insertions(+), 17 deletions(-)
 create mode 100644 mgb.ini
 delete mode 100644 mgb.yml

diff --git a/mgb.ini b/mgb.ini
new file mode 100644
index 0000000..aee6c9b
--- /dev/null
+++ b/mgb.ini
@@ -0,0 +1,12 @@
+[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
diff --git a/mgb.yml b/mgb.yml
deleted file mode 100644
index 05480b9..0000000
--- a/mgb.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-[user]
-id=@some_id\:matrix.org
-password=no-password
-display_name=MGB-Hitagi
-
-[handler]
-state_member=true
-room_message=true
diff --git a/src/config.rs b/src/config.rs
index 46a24fc..a2696c5 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -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",
-- 
GitLab