Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upDev #1
Open
Dev #1
Conversation
Adds a method to SlackIntegration.java that returns a formatted String to pass to Slack as a message
Currently there is an issue with the Mesonet API where the "weather condition" information hasn't been updated since October 30, so until it gets fixed it won't get included in Weatherbot's Slack response
This commit implements two separate threads, one to make API calls to the Mesonet API, and one to continually listen for Slack messages to respond to. This way there is no chance that a message will get skipped because the program is making the API call instead of listening for messages.
I left a lot of comments to try and show you as much as I could but in general it does look good. :) |
src/main/java/com/ruralsourcing/WeatherBot/model/Observation.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/model/ResponseModel.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/ApiTimerTask.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/ApiTimerTask.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/ApiTimerTask.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/SlackIntegration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/SlackIntegration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/SlackIntegration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/SlackIntegration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/SlackIntegration.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/SlackIntegration.java
Outdated
Show resolved
Hide resolved
Previously, API tokens for the Slack integration were stored as an environment variable, and the API token for the Mesonet API was hardcoded into the URL string. This commit places both tokens into a config.properties file and reads them from there, and puts config.properties into the .gitignore, so that API keys can remain separate and private among different users. config.sample.properties was created as a quick guide to the structure of the config.properties. The old API key that was hardcoded into the URL string has been disabled and replaced with a new key in the config.properties file for security purposes.
Abbreviation from String -> Str and Double -> Dbl was unneccesary
src/main/java/com/ruralsourcing/WeatherBot/service/PropertyIO.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/PropertyIO.java
Outdated
Show resolved
Hide resolved
src/main/java/com/ruralsourcing/WeatherBot/service/PropertyIO.java
Outdated
Show resolved
Hide resolved
In the PropertyIO class there were some best-practice issues that were fixed in this commit, such as an InputStream not in a try-with-resouces, a caught exception printing the error instead of the stack trace, and a potential race condition when the program starts
propertiesFileName will not be updated, so make it final. The properties variable isn't used outside of the constructore, so move the declaration inside the constructor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
katy-more-RSI commentedNov 12, 2019
This PR implements threading and allows the program to simultaneously listen for Slack messages and ping the Mesonet API for updated data.