Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding develpment var flag #55

Merged
merged 3 commits into from Dec 21, 2022
Merged

Adding develpment var flag #55

merged 3 commits into from Dec 21, 2022

Conversation

reharri7
Copy link
Member

When devilbot is handling an event, it checks accordingly to the event to see if it should respond. If it is a development stage and the event came from outside the test channel then the function returns. Resolves #54

@reharri7 reharri7 self-assigned this Dec 20, 2022
@reharri7
Copy link
Member Author

@jtmichelson It's worth noting that I thought about adding these checks to the main so there would be less code. Sometimes events don't come from a channel so I decided I would let the event handlers handle it for their specific circumstances. Maybe we should make some event_handler_trait that each event handler will implement?

@github-actions
Copy link

github-actions bot commented Dec 20, 2022

Test Results

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
1 suites ±0   0 💤 ±0 
1 files   ±0   0 ±0 

Results for commit 207824a. ± Comparison against base commit 87071df.

♻️ This comment has been updated with latest results.

@@ -23,6 +23,12 @@ pub async fn handle_message_event(body: &Value) {
.as_str()
.unwrap_or("invalid_enterprise_user_id");
let _user: &str = body["event"]["user"].as_str().unwrap_or("invalid_user");
let is_development = get_env_var("IS_DEVELOPMENT");
// Stop the function if this is a development environment and outside the test channel
if channel != "C0351GJ62Q0" && is_development == "true" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parse the is_development flag and use it as a regular boolean. Don't use string comparison here.

Something like:

let is_development: bool = get_env_var("IS_DEVELOPMENT").parse().unwrap();

Also you might want to do this once in main and pass it into the handlers.

@reharri7 reharri7 merged commit b45385f into main Dec 21, 2022
@reharri7 reharri7 deleted the rhett-add-dev-flag branch December 21, 2022 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Development_bot environment variable
2 participants