diff --git a/T_info.py b/T_info.py index 1817ca8..bba48ac 100644 --- a/T_info.py +++ b/T_info.py @@ -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. 🆘 **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) diff --git a/bot.py b/bot.py index fca3cec..eb976ae 100644 --- a/bot.py +++ b/bot.py @@ -474,6 +474,25 @@ def inline_query(update: Update, context: CallbackContext): # info(f"Inline command ran by {update.message.chat.username}") 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) results = [] @@ -490,7 +509,7 @@ def inline_query(update: Update, context: CallbackContext): ) if len(results) == 5: - update.inline_query.answer(results) + update.inline_query.answer(results, cache_time=60 * 60) info("Inline Command was successful") return update.inline_query.answer(results)