removed unnessesary env var (untested)

This commit is contained in:
2025-03-02 02:08:09 +01:00
parent 9a87342dd2
commit 2774b56e30
4 changed files with 17 additions and 18 deletions
+2 -2
View File
@@ -33,12 +33,12 @@ You can install Python modules by running `$ pip install {module}` or `$ python
| --- | --- | | --- | --- |
| `ASSISTANT_TOKEN` | The Discord bot token. (Create a Discord bot [here](https://discord.com/developers/docs/intro)!) | | `ASSISTANT_TOKEN` | The Discord bot token. (Create a Discord bot [here](https://discord.com/developers/docs/intro)!) |
| `ASSISTANT_TOKEN_TEST` | (Optional) A testing Discord bot token. This is only needed when the program is run with `-t` or `--test`. | | `ASSISTANT_TOKEN_TEST` | (Optional) A testing Discord bot token. This is only needed when the program is run with `-t` or `--test`. |
| `ASSISTANT_DM_USER` | (Optional) Your Discord user ID. The assistant will DM this user when *certain* errors occur. |
| `ASSISTANT_R_ID` | The id for the Reddit bot/account. (Create a Reddit bot [here](https://www.reddit.com/prefs/apps)!) | | `ASSISTANT_R_ID` | The id for the Reddit bot/account. (Create a Reddit bot [here](https://www.reddit.com/prefs/apps)!) |
| `ASSISTANT_R_TOKEN` | The token for the Reddit bot/account. | | `ASSISTANT_R_TOKEN` | The token for the Reddit bot/account. |
| `ASSISTANT_R_NAME` | The username of the Reddit bot/account. | | `ASSISTANT_R_NAME` | The username of the Reddit bot/account. |
| `ASSISTANT_R_PASS` | The password for the Reddit bot/account. | | `ASSISTANT_R_PASS` | The password for the Reddit bot/account. |
| `ASSISTANT_OWNERS` | (OPTIONAL) A list of Discord user IDs that "own" the bot. Separate each ID with a single comma and **no** spaces. | | `ASSISTANT_OWNERS` | (OPTIONAL) A list of Discord user IDs that "own" the bot. Separate each ID with a single comma and **no** spaces. This will allow the specified user IDs to run root commands such as `/stop`, it will also DM these users when *certain* errors occur. |
| `ASSISTANT_BK_WEEK_MODS` | (OPTIONAL) Same format as `ASSISTANT_OWNERS` but for |
### Required permissions: ### Required permissions:
**These are automatically set if you use the [official invite link](https://discord.com/oauth2/authorize?client_id=1212127255795335208&permissions=84992&integration_type=0&scope=bot).** **These are automatically set if you use the [official invite link](https://discord.com/oauth2/authorize?client_id=1212127255795335208&permissions=84992&integration_type=0&scope=bot).**
-3
View File
@@ -32,9 +32,6 @@ use tokio::time;
use websocket::send_cmd_json; use websocket::send_cmd_json;
// TODO: bot command permissions
#[derive(Parser, Serialize, Clone)] #[derive(Parser, Serialize, Clone)]
struct Args { struct Args {
#[arg(short = 'p', long, default_value = "2920", help = "Sets the port number, e.g 2200.")] #[arg(short = 'p', long, default_value = "2920", help = "Sets the port number, e.g 2200.")]
+14 -12
View File
@@ -179,24 +179,26 @@ pub async fn http_edit_msg(
pub async fn send_dm(msg: String, args: Args) { pub async fn send_dm(msg: String, args: Args) {
let uid = env::var("ASSISTANT_DM_USER"); let uids = env::var("ASSISTANT_OWNERS");
if uid.is_err() { return; } if uids.is_err() { return; }
let uids_split: Vec<String> = uids.unwrap()
.split(',')
.map(|s| s.to_string())
.collect();
let user = UserId::new(uid.unwrap().parse::<u64>().unwrap()); let token: String =
if !args.test { std::env::var("ASSISTANT_TOKEN") .expect("Missing ASSISTANT_TOKEN env var!") }
let token: String; else { std::env::var("ASSISTANT_TOKEN_TEST").expect("Missing ASSISTANT_TOKEN_TEST env var!") };
if !args.test {
token = std::env::var("ASSISTANT_TOKEN").expect("Missing ASSISTANT_TOKEN env var!");
}
else {
token = std::env::var("ASSISTANT_TOKEN_TEST").expect("Missing ASSISTANT_TOKEN_TEST env var!");
};
let http = Http::new(&token); let http = Http::new(&token);
let c_msg = CreateMessage::new().content(msg); let c_msg = CreateMessage::new().content(msg);
let _ = user.dm(http, c_msg).await; for uid in uids_split {
let user = UserId::new(uid.parse::<u64>().unwrap());
let _ = user.dm(http.as_ref(), c_msg.clone()).await;
}
} }
+1 -1
View File
@@ -134,7 +134,7 @@ async fn handle_message(msg: tungstenite::protocol::Message, args: Args) {
if text.starts_with("json:") { if text.starts_with("json:") {
let t_json: Value = serde_json::from_str(&text[5..]).unwrap(); let t_json: Value = serde_json::from_str(&text[5..]).unwrap();
if t_json.get("error").is_some() { if t_json.get("error").is_some() {
send_dm("Internal Python error!".to_string(), args).await; send_dm("Unknown internal Python error occurred!".to_string(), args).await;
} }
} }