├── .gitignore ├── README.md ├── main.py └── screenshots ├── screenshot.png ├── setup1.png ├── setup2.png └── setup3.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.swp 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Slack Stocks 2 | A slack slash command that gives you pricing information on a stock ticker 3 | 4 | ![Showcase](https://github.com/savala/slackStocks/blob/master/screenshots/screenshot.png) 5 | 6 | 7 | # Setup 8 | 9 | In your team settings, add a Slash Command Configuration 10 | ![Add a custom slash command configuration](https://github.com/savala/slackStocks/blob/master/screenshots/setup2.png) 11 | 12 | 13 | Make sure your settings are like so: 14 | 15 | 16 | 1. Add the command name "/stock" 17 | 2. Add in the URL like so "http:///stock 18 | * This assumes that you've deployed your application to AWS, heroku, digitalocean, or wherever you feel like so 19 | * Essentially, in slack when you type in " /stock xyz ", it will automatically call the above url as http://yourappurl/stock?text=xyz 20 | 3. Set the Method type to GET 21 | 4. If you've configured it correctly then you should be good to go! I've added a setup screenshot below as well 22 | 23 | ![Add a custom slash command configuration](https://github.com/savala/slackStocks/blob/master/screenshots/setup3.png) 24 | 25 | 26 | If you have any questions, concerns, or anything feel free to reach out to me [@saiavala](https://twitter.com/saiavala) 27 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, jsonify 2 | import requests 3 | 4 | app = Flask(__name__) 5 | 6 | @app.route('/stock') 7 | def stock(): 8 | result_text = "" 9 | try: 10 | ticker = request.args.get('text') 11 | # Get price, amount change, percent change, day high, day low 12 | url = "http://download.finance.yahoo.com/d/quotes.csv?s=" + ticker + "&f=l1c1p2hg" 13 | result = requests.get(url).text.split(',') 14 | result[2] = result[2].replace('"','') 15 | result[4] = result[4].replace('\n','') 16 | result_text = ("*" + ticker.upper() + "*" + "\n" 17 | "Price: " + result[0] + "\n" 18 | "Amt Change: " + result[1] + "\n" 19 | "% Change: " + result[2] + "\n" 20 | "Day High: " + result[3] + "\n" 21 | "Day Low: " + result[4]) 22 | except Exception as e: 23 | result_text = "Please enter in a valid ticker. ie /stock xyz" 24 | return result_text 25 | 26 | if __name__ == '__main__': 27 | app.debug = True 28 | app.run() 29 | -------------------------------------------------------------------------------- /screenshots/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/savala/slackStocks/7f117bb2efe3b0d2249c17006803a2a272402f19/screenshots/screenshot.png -------------------------------------------------------------------------------- /screenshots/setup1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/savala/slackStocks/7f117bb2efe3b0d2249c17006803a2a272402f19/screenshots/setup1.png -------------------------------------------------------------------------------- /screenshots/setup2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/savala/slackStocks/7f117bb2efe3b0d2249c17006803a2a272402f19/screenshots/setup2.png -------------------------------------------------------------------------------- /screenshots/setup3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/savala/slackStocks/7f117bb2efe3b0d2249c17006803a2a272402f19/screenshots/setup3.png --------------------------------------------------------------------------------