mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-15 23:06:40 +00:00
finisheing touches on #82
This commit is contained in:
parent
f67cb398ac
commit
727e08a309
@ -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)
|
||||
|
||||
|
21
bot.py
21
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user