From 028948303870563f57e60defa4ed26d28c27c6d4 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 13 Apr 2018 15:47:25 -0700 Subject: [PATCH] Consolodating the stock message interpolation and adding a help section for tts --- app/help_methods.py | 6 +++++- app/stock.py | 16 +++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/help_methods.py b/app/help_methods.py index d781586b..714a49b8 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -94,7 +94,11 @@ def get_help_message(method): 'stock': [ 'Returns basic stock information for the stock you entered.', '\nUsage: !stock AAPL TSLA' - ] + ], + 'tts': [ + 'Uploads a file with the specified text as an MP3. This is advanced shitposting', + '\nUsage: !tts who watches the watchmen?' + ], } # Print out every help method diff --git a/app/stock.py b/app/stock.py index 65da25ae..f8c71c16 100644 --- a/app/stock.py +++ b/app/stock.py @@ -13,12 +13,14 @@ def parse_share(msg): def get_stock(share_name): - url = "https://api.iextrading.com/1.0/stock/{}/quote".format(share_name) - request = requests.get(url).json() + request = requests.get("https://api.iextrading.com/1.0/stock/{}/quote".format(share_name)).json() - open_price = request['open'] - curr_price = request['latestPrice'] - change = request['change'] - changePercent = request['changePercent'] return '```Company Name: {}\nSymbol: {}\nSector: {}\n\nOpen: ${}\nCurrently: ${}\nChange: ${}\nChange percent {}%```'.format( - request['companyName'], request['symbol'], request['sector'], open_price, curr_price, change, changePercent) + request['companyName'], + request['symbol'], + request['sector'], + request['open'], + request['latestPrice'], + request['change'], + request['changePercent'] + )