1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-06-16 07:16:40 +00:00

fixed issues #13

This commit is contained in:
Anson 2019-03-22 12:37:57 -07:00
parent b7fb4df4a8
commit 2ebcf5f8d8

View File

@ -11,6 +11,7 @@ import credentials
import tickerInfo
TOKEN = credentials.secrets["TELEGRAM_TOKEN"]
TICKER_REGEX = "[$]([a-zA-Z]{1,4})"
# Enable logging
logging.basicConfig(
@ -41,7 +42,7 @@ def news(bot, update):
try:
# regex to find tickers in messages, looks for up to 4 word characters following a dollar sign and captures the 4 word characters
tickers = re.findall("[$](\w{1,4})", message)
tickers = re.findall(TICKER_REGEX, message)
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
## Checks if a ticker was passed in
@ -96,10 +97,11 @@ def stockInfo(bot, update):
try:
# regex to find tickers in messages, looks for up to 4 word characters following a dollar sign and captures the 4 word characters
tickers = re.findall("[$](\w{1,4})", message)
tickers = re.findall(TICKER_REGEX, message)
tickerData = tickerInfo.tickerQuote(tickers)
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
if len(tickers) > 0:
tickerData = tickerInfo.tickerQuote(tickers)
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
for ticker in tickers:
ticker = ticker.upper()