1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-07-26 08:01:42 +00:00

fixed environ vars since now theres more than 1

This commit is contained in:
2019-05-28 05:33:16 -07:00
parent 4da5d9933f
commit da5d071f34
2 changed files with 7 additions and 10 deletions

View File

@@ -1,12 +1,11 @@
import json
import os
import re
import time
import urllib.request
from datetime import datetime
import cred
IEX_TOKEN = os.environ["IEX"]
def getTickers(text: str):
"""
Takes a blob of text and returns any stock tickers found.
@@ -24,7 +23,7 @@ def tickerDataReply(tickers: list):
tickerReplies = {}
for ticker in tickers:
IEXURL = (
f"https://cloud.iexapis.com/stable/stock/{ticker}/quote?token={cred.secret}"
f"https://cloud.iexapis.com/stable/stock/{ticker}/quote?token={IEX_TOKEN}"
)
try:
with urllib.request.urlopen(IEXURL) as url:
@@ -52,7 +51,7 @@ def tickerDividend(tickers: list):
messages = {}
for ticker in tickers:
IEXurl = f"https://cloud.iexapis.com/stable/stock/{ticker}/dividends/next?token={cred.secret}"
IEXurl = f"https://cloud.iexapis.com/stable/stock/{ticker}/dividends/next?token={IEX_TOKEN}"
with urllib.request.urlopen(IEXurl) as url:
data = json.loads(url.read().decode())
if data:
@@ -77,4 +76,3 @@ def tickerDividend(tickers: list):
messages[ticker] = f"{ticker} either doesn't exist or pays no dividend."
return messages