From dec7cb0236bb86e61d62b5df1b9ee07d482e4849 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Sat, 2 Dec 2023 02:00:51 -0500 Subject: [PATCH] Environment variables can be defined in .env file instead --- .gitignore | 3 ++- README.md | 5 ++--- src/main.rs | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2bc6dcd..188c46a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ target/ /target # env -.envrc \ No newline at end of file +.envrc +.env \ No newline at end of file diff --git a/README.md b/README.md index f1df87b..a55b0be 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ test ModulatingForceBot ## Usage -Set the following environment variables +1. Set the following environment variables ; either on environment variables or in an .env file `access_token = ` - -`bot_channels = ,` \ No newline at end of file +`bot_channels = ,` diff --git a/src/main.rs b/src/main.rs index 5926d6d..769afb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,11 +8,14 @@ use twitch_irc::message::ServerMessage; use std::env; use std::time::Instant; use rand::Rng; - +use dotenv::dotenv; // mod helpers; #[tokio::main] pub async fn main() { + + dotenv().ok(); + let login_name = "modulatingforcebot".to_owned(); let oauth_token = env::var("access_token").unwrap().to_owned();