removed unnessesary env var (untested)
This commit is contained in:
@@ -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_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_TOKEN` | The token for 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_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:
|
||||
**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).**
|
||||
|
||||
@@ -32,9 +32,6 @@ use tokio::time;
|
||||
use websocket::send_cmd_json;
|
||||
|
||||
|
||||
// TODO: bot command permissions
|
||||
|
||||
|
||||
#[derive(Parser, Serialize, Clone)]
|
||||
struct Args {
|
||||
#[arg(short = 'p', long, default_value = "2920", help = "Sets the port number, e.g 2200.")]
|
||||
|
||||
+13
-11
@@ -179,24 +179,26 @@ pub async fn http_edit_msg(
|
||||
|
||||
|
||||
pub async fn send_dm(msg: String, args: Args) {
|
||||
let uid = env::var("ASSISTANT_DM_USER");
|
||||
if uid.is_err() { return; }
|
||||
let uids = env::var("ASSISTANT_OWNERS");
|
||||
if uids.is_err() { return; }
|
||||
|
||||
let user = UserId::new(uid.unwrap().parse::<u64>().unwrap());
|
||||
let uids_split: Vec<String> = uids.unwrap()
|
||||
.split(',')
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
|
||||
let token: String;
|
||||
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 token: String =
|
||||
if !args.test { std::env::var("ASSISTANT_TOKEN") .expect("Missing ASSISTANT_TOKEN env var!") }
|
||||
else { std::env::var("ASSISTANT_TOKEN_TEST").expect("Missing ASSISTANT_TOKEN_TEST env var!") };
|
||||
|
||||
let http = Http::new(&token);
|
||||
|
||||
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
@@ -134,7 +134,7 @@ async fn handle_message(msg: tungstenite::protocol::Message, args: Args) {
|
||||
if text.starts_with("json:") {
|
||||
let t_json: Value = serde_json::from_str(&text[5..]).unwrap();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user