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

Initial Documentation #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ typings/
.dynamodb/

keys/

#Documentation
docs/
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
[![Build Status](https://cloud.drone.io/api/badges/rpiambulance/whoson/status.svg)](https://cloud.drone.io/rpiambulance/whoson)

[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com)


# whoson
Integrates RPI Ambulance's crew schedule into Slack
**whoson** is a Slack integration that allows members to see who is scheduled for night shifts.

## Integration mechanics
Using **whoson** is easy! In its most basic form, the integration can be run by typing `/whoson` into a Slack channel. This will return:

* Tonight's crew—if between 0900 and 1800 hours
* The current crew—if between 1800 and 0600 hours
* Last night and tonight's crews—if between 0600 and 0900 hours

### Other commands
**whoson** can also display other days' crews, including yesterday and any day up to a week from now.

Simply run `/whoson <parameter>` to get the desired response. Parameters are case-insensitive and include:

- `Monday`, `Tuesday`, or any other day of the week
- Tip: you can abbreviate days of the week! Try `Mon` or `Thurs`, for instance
- `Yesterday` or `yest`
- `Tomorrow` or `tom`
- `Week`

As a note, if you type the current day of the week, **whoson** will return the crew for *a week from today*. That is, if it is currently Wednesday, running `/whoson wed` will return *next* Wednesday's crew.

## Important files
**whoson** runs on the web server, using [a php file](https://github.com/rpiambulance/website/blob/master/slack-whoson.php) to grab database data. This integration will, eventually, be incorporated into [rampart](https://github.com/rpiambulance/rampart).

## Documentation
Generate JSDocs by running `jsdoc -R README.md -d docs/ utilities/*.js server.js`.


## Credits

### Developers

- [Dan Bruce](https://github.com/ddbruce)

### License

**whoson** is provided under the [MIT License](https://opensource.org/licenses/MIT).

### Contact

For any question, comments, or concerns, email [[email protected]](mailto:[email protected]), [create an issue](https://github.com/rpiambulance/whoson/issues/new), or open up a pull request.
5 changes: 5 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const RPIA_WEB_TOKEN = process.env.RPIA_WEB_TOKEN;
const SLACK_SIGNING_TOKEN = process.env.SLACK_SIGNING_TOKEN;
const PORT = process.env.NODE_PORT || 3000;

/**
* Provide handling for whoson command. Allowed day options are handled by cases. Once date is calculated and formatted,
* querey website database for who is on. Returned result from website query is expected to be a string of riders.
* That is then posted as the message.
*/
app.post("/whoson", async ({ body: { token, text } }, res) => {
if (token != SLACK_SIGNING_TOKEN) {
res.send("Sorry, you're not authenticated!");
Expand Down
6 changes: 6 additions & 0 deletions utilities/helperFunctions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Function to convert javascript date object to date string as formated in website database.
*
* @param {date} date - date object to be converted
* @returns {string} datestring - "year-month-day" formatted string
*/
const makeWhosonDate = date => {
const year = date.getFullYear();
let month = date.getMonth() + 1;
Expand Down