update README, security, and user friendliness
This commit is contained in:
@@ -24,6 +24,17 @@ An automation tool for Byte Dice. It's both a Discord and Reddit bot in one prog
|
||||
* typing
|
||||
* websockets
|
||||
|
||||
**Environment variables:**
|
||||
| **Name** | **Description** |
|
||||
| --- | --- |
|
||||
| `ASSISTANT_TOKEN` | The Discord bot token. |
|
||||
| `ASSISTANT_TOKEN_TEST` | (Optional) A testing Discord bot token. This is only needed when the program is ran 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. |
|
||||
| `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. |
|
||||
|
||||
You can install Python modules by running `$ pip install {module}` or `$ python -m pip install {module}` in a terminal.
|
||||
|
||||
**How to run:**
|
||||
|
||||
+4
-2
@@ -177,8 +177,10 @@ pub async fn http_edit_msg(
|
||||
|
||||
|
||||
pub async fn send_dm(msg: String, args: Args) {
|
||||
let uid = env::var("ASSISTANT_DM_USER").expect("Missing ASSISTANT_DM_USER env var!").parse::<u64>().unwrap();
|
||||
let user = UserId::new(uid);
|
||||
let uid = env::var("ASSISTANT_DM_USER");
|
||||
if uid.is_err() { return; }
|
||||
|
||||
let user = UserId::new(uid.unwrap().parse::<u64>().unwrap());
|
||||
|
||||
let token: String;
|
||||
if !args.test {
|
||||
|
||||
+13
-6
@@ -7,8 +7,15 @@ from macros import *
|
||||
|
||||
class Bot:
|
||||
args: dict = {"NO_RUST": True, "dev": True, "py": True, "port": 2920}
|
||||
password: str = os.environ.get("ASSISTANT_R_PASS")
|
||||
r_id: str = os.environ.get("ASSISTANT_R_ID")
|
||||
secret: str = os.environ.get("ASSISTANT_R_TOKEN")
|
||||
username: str = os.environ.get("ASSISTANT_R_NAME")
|
||||
password: str = os.environ.get("ASSISTANT_R_PASS")
|
||||
|
||||
useragent: str =\
|
||||
f"{username} by u/RandomPersonDotExe aka u/Byte_Dice"\
|
||||
if r_id == "YmZjr4zLr2qtHdpQXtj0sBOOdJzrXQ"\
|
||||
else f"{username} (original program by u/RandomPersonDotExe aka u/Byte_Dice)"
|
||||
|
||||
if password is None:
|
||||
py_error("Environment variable \"ASSISTANT_R_PASS\" is null!")
|
||||
@@ -17,11 +24,11 @@ class Bot:
|
||||
|
||||
def __init__(self):
|
||||
self.r: praw.Reddit = praw.Reddit(
|
||||
client_id="iCSRWS6PMlTLwmylCJRYmA",
|
||||
client_secret=self.secret,
|
||||
username="ByteDiceAssistant",
|
||||
password=self.password,
|
||||
user_agent="Byte Dice Assistant by u/RandomPersonDotExe aka u/Byte_Dice"
|
||||
client_id = self.r_id,
|
||||
client_secret = self.secret,
|
||||
username = self.username,
|
||||
password = self.password,
|
||||
user_agent = self.useragent
|
||||
)
|
||||
self.sr = None
|
||||
self.data_f: TextIOWrapper = None
|
||||
|
||||
Reference in New Issue
Block a user