-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RyanSept/develop
DevelopSuccessfully integrated and merged
- Loading branch information
Showing
14 changed files
with
509 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Sakabot | ||
Sakabot is a slackbot designed to help Andelans find the owners of equipment and report them either lost or found. | ||
It's been built in part using this wrapper to the slack rtm api https://github.com/lins05/slackbot. | ||
|
||
### Getting Started | ||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. | ||
|
||
### Prerequisites | ||
You'll need a slack api bot token https://api.slack.com/bot-users. | ||
|
||
### Installing | ||
Clone the repo from Github by running `$ git clone [email protected]:RyanSept/sakabot.git` | ||
|
||
Change directory into package `$ cd sakabot` | ||
|
||
Install the dependencies by running `$ pip install requirements.txt` | ||
|
||
You can set the required environment variables like so | ||
|
||
``` | ||
$ export BOT_TOKEN=<SLACK_API_BOT_TOKEN> | ||
$ export MONGODB_URI=<URI_TO_MONGO_DATABASE> | ||
$ export ERRORS_TO=<SLACK_USER_TO_SEND_ERRORS_TO> | ||
``` | ||
|
||
Before running you need to setup the database and populate it by running the sprawler on the OPs spreadsheet with your email credentials | ||
on it. To run the sprawler, you need credentials. To get these, you need to setup a project on the Google Developers Console. | ||
Follow this guide https://developers.google.com/sheets/api/quickstart/python and copy the credentials file you download | ||
to app/sprawler/credentials as sakabot-cred.json. Copy the client email value in the credentials file you got and share | ||
the spreadsheet with that email. | ||
|
||
### Deployment | ||
To deploy on heroku, you need to push setup the app on heroku, add the appropriate configs(see installing section), set up a | ||
mongodb and scale the dyno `heroku ps:scale worker=1` | ||
|
||
### Usage | ||
*Searching for an item's owner* | ||
To search for an item's owner send `find charger|mac|thunderbolt <item_id>` to _@sakabot_. | ||
eg. `find charger 41` | ||
|
||
*Reporting that you've lost an item* | ||
When you lose an item, there's a chance that somebody has found it and submitted it to Sakabot. In that case we'll tell you who found it, otherwise, we'll slack you in case anyone reports they found it. To report an item as lost send `lost charger|mac|thunderbolt <item_id>` to _@sakabot._ | ||
eg. `lost thunderbolt 33` | ||
|
||
*Submit a found item* | ||
When you find a lost item you can report that you found it and in case a user had reported it lost, we'll slack them immediately telling them you found it. To report that you found an item send `found charger|mac|thunderbolt <item_id>` to _@sakabot_ | ||
eg. `found mac 67` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
from pymongo import MongoClient | ||
from slackclient import SlackClient | ||
from app.config import MONGODB, BOT_TOKEN | ||
import pymongo | ||
from app.config import MONGODB_URI, BOT_TOKEN | ||
|
||
|
||
mongodb_client = MongoClient() | ||
db = mongodb_client[MONGODB] | ||
mongodb_client = MongoClient(MONGODB_URI) | ||
db = mongodb_client.get_default_database() | ||
|
||
# db collection | ||
chargers = db.chargers | ||
macbooks = db.macbooks | ||
thunderbolts = db.thunderbolts | ||
lost = db.lost | ||
found = db.found | ||
slack_handles = db.slack_handles | ||
|
||
# slack client | ||
slack_client = SlackClient(BOT_TOKEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import os | ||
HOME_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
# slack bot token | ||
BOT_TOKEN = os.getenv("BOT_TOKEN") | ||
# get from env or use default mongo uri | ||
MONGODB_URI = os.getenv('MONGODB_URI') or "mongodb://127.0.0.1:27017/saka" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.