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

finisheing touches on #82

This commit is contained in:
Anson Biggs 2021-11-06 13:17:13 -07:00
parent f67cb398ac
commit 727e08a309
2 changed files with 21 additions and 2 deletions

View File

@ -39,7 +39,7 @@ Simply calling a symbol in any message that the bot can see will also return the
- `/help` Get some help using the bot. 🆘 - `/help` Get some help using the bot. 🆘
**Inline Features** **Inline Features**
You can type @SimpleStockBot `[search]` in any chat or direct message to search for the stock bots full list of stock symbols and return the price of the ticker. Then once you select the ticker want the bot will send a message as you in that chat with the latest stock price. You can type @SimpleStockBot `[search]` in any chat or direct message to search for the stock bots full list of stock and crypto symbols and return the price. Then once you select the ticker want the bot will send a message as you in that chat with the latest stock price. Prices may be delayed by up to an hour.
Market data is provided by [IEX Cloud](https://iexcloud.io) Market data is provided by [IEX Cloud](https://iexcloud.io)

21
bot.py
View File

@ -474,6 +474,25 @@ def inline_query(update: Update, context: CallbackContext):
# info(f"Inline command ran by {update.message.chat.username}") # info(f"Inline command ran by {update.message.chat.username}")
info(f"Query: {update.inline_query.query}") info(f"Query: {update.inline_query.query}")
ignored_queries = {"$", "$$", " ", ""}
if update.inline_query.query.strip() in ignored_queries:
default_message = """
You can type:\n@SimpleStockBot `[search]`\nin any chat or direct message to search for the stock bots full list of stock and crypto symbols and return the price.
"""
update.inline_query.answer(
[
InlineQueryResultArticle(
str(uuid4()),
title="Please enter a query. It can be a ticker or a name of a company.",
input_message_content=InputTextMessageContent(
default_message, parse_mode=telegram.ParseMode.MARKDOWN
),
)
]
)
matches = s.inline_search(update.inline_query.query) matches = s.inline_search(update.inline_query.query)
results = [] results = []
@ -490,7 +509,7 @@ def inline_query(update: Update, context: CallbackContext):
) )
if len(results) == 5: if len(results) == 5:
update.inline_query.answer(results) update.inline_query.answer(results, cache_time=60 * 60)
info("Inline Command was successful") info("Inline Command was successful")
return return
update.inline_query.answer(results) update.inline_query.answer(results)