From da5d071f3412df725959175c58bf87b6eeafb741 Mon Sep 17 00:00:00 2001 From: Anson Date: Tue, 28 May 2019 05:33:16 -0700 Subject: [PATCH] fixed environ vars since now theres more than 1 --- bot.py | 7 +++---- functions.py | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bot.py b/bot.py index c5122d9..0daec43 100644 --- a/bot.py +++ b/bot.py @@ -3,11 +3,10 @@ import logging import os import telegram +from functions import * from telegram.ext import CommandHandler, Filters, MessageHandler, Updater -from functions import * - -TOKEN = os.environ["TELEGRAM"] +TELEGRAM_TOKEN = os.environ["TELEGRAM"] TICKER_REGEX = "[$]([a-zA-Z]{1,4})" # Enable logging @@ -76,7 +75,7 @@ def error(bot, update, error): def main(): """Start the bot.""" # Create the EventHandler and pass it your bot's token. - updater = Updater(TOKEN) + updater = Updater(TELEGRAM_TOKEN) # Get the dispatcher to register handlers dp = updater.dispatcher diff --git a/functions.py b/functions.py index f84d7fe..a714205 100644 --- a/functions.py +++ b/functions.py @@ -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 -