1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-07-26 08:01:26 +00:00

added stat command

This commit is contained in:
2020-10-02 18:34:55 -07:00
parent e603c5345a
commit 6cfbbeb992
2 changed files with 66 additions and 13 deletions

25
bot.py
View File

@@ -48,7 +48,7 @@ def help(update, context):
def symbol_detect(update, context):
"""
Runs on any message that doesn't have a command and searches for symbols, then returns the prices of any symbols found.
Runs on any message that doesn't have a command and searches for symbols, then returns the prices of any symbols found.
"""
message = update.message.text
chat_id = update.message.chat_id
@@ -165,10 +165,29 @@ def intra(update, context):
buf.seek(0)
update.message.reply_photo(
photo=buf, caption=f"", parse_mode=telegram.ParseMode.MARKDOWN,
photo=buf,
caption=f"",
parse_mode=telegram.ParseMode.MARKDOWN,
)
def stat(update, context):
"""
https://iexcloud.io/docs/api/#key-stats
"""
message = update.message.text
chat_id = update.message.chat_id
symbols = s.find_symbols(message)
if symbols:
context.bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING)
for reply in s.stat_reply(symbols).items():
update.message.reply_text(
text=reply[1], parse_mode=telegram.ParseMode.MARKDOWN
)
def inline_query(update, context):
"""
Handles inline query.
@@ -232,6 +251,8 @@ def main():
dp.add_handler(CommandHandler("div", dividend))
dp.add_handler(CommandHandler("news", news))
dp.add_handler(CommandHandler("info", info))
dp.add_handler(CommandHandler("stat", stat))
dp.add_handler(CommandHandler("stats", stat))
dp.add_handler(CommandHandler("search", search))
dp.add_handler(CommandHandler("intraday", intra))
dp.add_handler(CommandHandler("intra", intra))