From 704dd2dcd897a3fb445a90a26b6a7b69024e982d Mon Sep 17 00:00:00 2001 From: ToastXC <100072983+toastxc@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:42:26 +0800 Subject: [PATCH] moved development to env file --- .env.example | 4 ++++ .gitignore | 1 + Cargo.toml | 3 +++ src/tests/bot-id.txt | 0 src/tests/bot-token.txt | 1 - src/tests/mod.rs | 18 +++++++++++++----- src/tests/self-token.txt | 1 - 7 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 .env.example delete mode 100644 src/tests/bot-id.txt delete mode 100644 src/tests/bot-token.txt delete mode 100644 src/tests/self-token.txt diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..023e96c --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +DEVEL_BOT_ID="" +DEVEL_USER_ID="" +DEVEL_BOT_TOKEN="" +DEVEL_USER_TOKEN="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index ef2a8bb..6574b49 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ Cargo.lock src/main.rs src/tests/bot-token.txt +/.env diff --git a/Cargo.toml b/Cargo.toml index ceef8ff..875bb6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,9 @@ reywen_http = { version = "0.1.18", features = ["serde"]} native-tls = "0.2.11" url = "2.5.0" +# development +dotenv = "0.15.0" + [features] # engine option | mandatory default = ["reywen_http/hyper_engine"] diff --git a/src/tests/bot-id.txt b/src/tests/bot-id.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/tests/bot-token.txt b/src/tests/bot-token.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/tests/bot-token.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 3451f73..5183e82 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -6,6 +6,8 @@ pub mod session; pub mod users; pub mod websocket; +use std::env; +use dotenv::*; use crate::client::Client; pub mod emoji; @@ -19,19 +21,25 @@ pub const USER_NOTSELF: &str = "01H2PWB11T4DY3E76Y8PHFT3EX"; // enter values here for testing pub fn tester_bot() -> Client { + dotenv().ok(); + Client::from_token( - include_str!("bot-token.txt").replace([' ', '\n'], ""), - include_str!("bot-id.txt").replace([' ', '\n'], ""), + + env::var("DEVEL_BOT_TOKEN").unwrap(), + env::var("DEVEL_BOT_ID").unwrap(), + true, ) .unwrap() } pub fn tester_user() -> Client { + dotenv().ok(); Client::from_token( - include_str!("self-token.txt").replace([' ', '\n'], ""), - include_str!("self-id.txt").replace([' ', '\n'], ""), - true, + env::var("DEVEL_USER_TOKEN").unwrap(), + env::var("DEVEL_USER_ID").unwrap(), + + false, ) .unwrap() } diff --git a/src/tests/self-token.txt b/src/tests/self-token.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/tests/self-token.txt +++ /dev/null @@ -1 +0,0 @@ -