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