Skip to content

Commit

Permalink
Only run dotenv stuffs if .env exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dracarys18 committed Apr 11, 2022
1 parent 7e39665 commit 8fcb634
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::error::TweetResult;
use egg_mode::KeyPair;
use egg_mode::Token;
use std::path::PathBuf;
use teloxide::prelude::{AutoSend, RequesterExt};
use teloxide::Bot;

Expand All @@ -15,7 +16,10 @@ pub struct Config {

impl Config {
pub fn new() -> TweetResult<Self> {
dotenv::dotenv()?;
//Only run dotenv stuff if .env exists
if PathBuf::from("./.env").exists() {
dotenv::dotenv()?;
}
let accounts: Vec<String> = std::env::var("ACCOUNTS")
.expect("Missing ACCOUNTS")
.split(',')
Expand Down

0 comments on commit 8fcb634

Please sign in to comment.