Consolodating the stock message interpolation and adding a help section for tts

This commit is contained in:
Luke Robles 2018-04-13 15:47:25 -07:00
parent 74c1d18749
commit 0289483038
2 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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']
)