From d2c2f09ec38e94067dfc5eb669a9d8f7434ab6c7 Mon Sep 17 00:00:00 2001
From: Kiril Kovachev <ktkovachev@gmail.com>
Date: Fri, 9 May 2025 00:05:20 +0100
Subject: [PATCH] feat: Make OAuth2 token the default credential for
 authentification

---
 mwbot_template.toml | 4 ++--
 src/main.rs         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mwbot_template.toml b/mwbot_template.toml
index 84a3364..9a7d13f 100644
--- a/mwbot_template.toml
+++ b/mwbot_template.toml
@@ -4,5 +4,5 @@ rest_url = "{}"
 
 [auth]
 username = "{}"
-password = "{}"
-# oauth2_token = "{}"
+# password = "{}"
+oauth2_token = "{}"
diff --git a/src/main.rs b/src/main.rs
index 6b29d76..b8ff8ed 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,7 +26,7 @@ struct SetupArgs {
     username: String,
     /// Specify the botpassword of the bot
     #[arg(long, env = "MW_BOTPASSWORD")]
-    botpassword: String,
+    botpassword: Option<String>,
     /// Specify the OAuth2 token of the bot
     #[arg(long, env = "MW_OAUTH2")]
     oauth2_token: String,
@@ -52,7 +52,7 @@ fn read_config_template() -> Result<String, std::io::Error> {
 }
 
 fn fill_config_template(config_template: String, args: SetupArgs) -> String {
-    formatx!(config_template, args.api_url, args.rest_url, args.username, args.botpassword, args.oauth2_token).unwrap()
+    formatx!(config_template, args.api_url, args.rest_url, args.username, args.botpassword.unwrap_or("".into()), args.oauth2_token).unwrap()
 }
 
 // Fix permissions on UNIX-like systems, since mwbot-rs doesn't like to read configs with loose permissions.