Bot admins in env file #22

Merged
modulatingforce merged 7 commits from haru_test into master 2024-04-09 13:48:55 -04:00
2 changed files with 16 additions and 2 deletions
Showing only changes of commit f7881fa07d - Show all commits

View file

@ -12,4 +12,5 @@ login_name = <botname>
access_token = <oauth token>
bot_channels = <chnl1>,<chnl2>
prefix = <prefix>
bot_admins = <admins>
```

View file

@ -20,9 +20,22 @@ fn adminvector() -> Vec<String> {
dotenv().ok();
let mut admins = Vec::new();
for admin in env::var("bot_admins").unwrap().split(',') {
admins.push(String::from(admin))
// for admin in env::var("bot_admins").unwrap().split(',') {
// admins.push(String::from(admin))
// }
// 03.17 - Forcen - Suggesting below instead :
/*
- this will push only if env::var() returns Ok() ;
otherwise (like in Err(_)) do nothing
*/
if let Ok(value) = env::var("bot_admins") {
for admin in value.split(',') {
admins.push(String::from(admin))
}
}
admins
}