mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-06-16 15:06:53 +00:00
closes #76
This commit is contained in:
parent
c34af4cd40
commit
f67cb398ac
@ -36,6 +36,9 @@ class IEX_Symbol:
|
||||
"""
|
||||
try:
|
||||
self.IEX_TOKEN = os.environ["IEX"]
|
||||
|
||||
if self.IEX_TOKEN == "TOKEN":
|
||||
self.IEX_TOKEN = ""
|
||||
except KeyError:
|
||||
self.IEX_TOKEN = ""
|
||||
warning(
|
||||
@ -122,6 +125,10 @@ class IEX_Symbol:
|
||||
str
|
||||
Human readable text on status of IEX API
|
||||
"""
|
||||
|
||||
if self.IEX_TOKEN == "":
|
||||
return "The `IEX_TOKEN` is not set so Stock Market data is not available."
|
||||
|
||||
resp = r.get(
|
||||
"https://pjmps0c34hp7.statuspage.io/api/v2/status.json",
|
||||
timeout=15,
|
||||
|
13
bot.py
13
bot.py
@ -85,14 +85,17 @@ def license(update: Update, context: CallbackContext):
|
||||
def status(update: Update, context: CallbackContext):
|
||||
"""Gather status of bot and dependant services and return important status updates."""
|
||||
warning(f"Status command ran by {update.message.chat.username}")
|
||||
bot_resp = datetime.datetime.now(update.message.date.tzinfo) - update.message.date
|
||||
bot_resp_time = (
|
||||
datetime.datetime.now(update.message.date.tzinfo) - update.message.date
|
||||
)
|
||||
|
||||
bot_status = s.status(
|
||||
f"It took {bot_resp_time.total_seconds()} seconds for the bot to get your message."
|
||||
)
|
||||
|
||||
update.message.reply_text(
|
||||
text=s.status(
|
||||
f"It took {bot_resp.total_seconds()} seconds for the bot to get your message."
|
||||
),
|
||||
text=bot_status,
|
||||
parse_mode=telegram.ParseMode.MARKDOWN,
|
||||
disable_notification=True,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user