mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 23:26:52 +00:00
fixed issues #13
This commit is contained in:
parent
b7fb4df4a8
commit
2ebcf5f8d8
@ -11,6 +11,7 @@ import credentials
|
|||||||
import tickerInfo
|
import tickerInfo
|
||||||
|
|
||||||
TOKEN = credentials.secrets["TELEGRAM_TOKEN"]
|
TOKEN = credentials.secrets["TELEGRAM_TOKEN"]
|
||||||
|
TICKER_REGEX = "[$]([a-zA-Z]{1,4})"
|
||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@ -41,7 +42,7 @@ def news(bot, update):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# regex to find tickers in messages, looks for up to 4 word characters following a dollar sign and captures the 4 word characters
|
# 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)
|
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
|
||||||
|
|
||||||
## Checks if a ticker was passed in
|
## Checks if a ticker was passed in
|
||||||
@ -96,8 +97,9 @@ def stockInfo(bot, update):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# regex to find tickers in messages, looks for up to 4 word characters following a dollar sign and captures the 4 word characters
|
# 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)
|
||||||
|
|
||||||
|
if len(tickers) > 0:
|
||||||
tickerData = tickerInfo.tickerQuote(tickers)
|
tickerData = tickerInfo.tickerQuote(tickers)
|
||||||
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
|
bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user