1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-07-25 07:31:48 +00:00

Fixed Inline #55

This commit is contained in:
2021-03-30 11:36:52 -07:00
parent 8dd3ef772f
commit 144dd1d218
4 changed files with 75 additions and 8 deletions

18
bot.py
View File

@@ -8,6 +8,8 @@ import json
import traceback
import mplfinance as mpf
from uuid import uuid4
import telegram
from telegram import (
InlineQueryResultArticle,
@@ -383,18 +385,19 @@ def inline_query(update: Update, context: CallbackContext):
Does a fuzzy search on input and returns stocks that are close.
"""
matches = s.search_symbols(update.inline_query.query)
matches = s.search_symbols(update.inline_query.query)[:]
symbols = " ".join([match[1].split(":")[0] for match in matches])
prices = s.price_reply(s.find_symbols(symbols))
prices = s.batch_price_reply(s.find_symbols(symbols))
# print(len(matches), len(prices))
# print(prices)
results = []
print(update.inline_query.query)
for match, price in zip(matches, prices):
print(match)
try:
results.append(
InlineQueryResultArticle(
match[0],
str(uuid4()),
title=match[1],
input_message_content=InputTextMessageContent(
price, parse_mode=telegram.ParseMode.MARKDOWN
@@ -404,10 +407,11 @@ def inline_query(update: Update, context: CallbackContext):
except TypeError:
logging.warning(str(match))
pass
if len(results) == 10:
print(match[0], "\n\n\n")
if len(results) == 5:
update.inline_query.answer(results)
return
update.inline_query.answer(results)
def rand_pick(update: Update, context: CallbackContext):