mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-06-16 15:06:53 +00:00
patch to stop inline queries from failing until stock data is added
This commit is contained in:
parent
160170409e
commit
541be6c783
@ -123,7 +123,8 @@ class Router:
|
||||
Each tuple contains: (Symbol, Issue Name).
|
||||
"""
|
||||
|
||||
df = pd.concat([self.stock.symbol_list, self.crypto.symbol_list])
|
||||
# df = pd.concat([self.stock.symbol_list, self.crypto.symbol_list])
|
||||
df = self.crypto.symbol_list
|
||||
|
||||
df = df[df["description"].str.contains(search, regex=False, case=False)].sort_values(
|
||||
by="type_id", key=lambda x: x.str.len()
|
||||
@ -353,7 +354,8 @@ class Router:
|
||||
return "Trending data is not currently available."
|
||||
|
||||
def random_pick(self) -> str:
|
||||
choice = random.choice(list(self.stock.symbol_list["description"]) + list(self.crypto.symbol_list["description"]))
|
||||
# choice = random.choice(list(self.stock.symbol_list["description"]) + list(self.crypto.symbol_list["description"]))
|
||||
choice = random.choice(list(self.crypto.symbol_list["description"]))
|
||||
hold = (datetime.date.today() + datetime.timedelta(random.randint(1, 365))).strftime("%b %d, %Y")
|
||||
|
||||
return f"{choice}\nBuy and hold until: {hold}"
|
||||
|
@ -34,6 +34,10 @@ from T_info import T_info
|
||||
|
||||
# Enable logging
|
||||
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
|
||||
|
||||
# set higher logging level for httpx to avoid all GET and POST requests being logged
|
||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
TELEGRAM_TOKEN = os.environ["TELEGRAM"]
|
||||
@ -316,13 +320,16 @@ async def trending(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
)
|
||||
|
||||
|
||||
async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
"""
|
||||
Handles inline query. Searches by looking if query is contained
|
||||
in the symbol and returns matches in alphabetical order.
|
||||
"""
|
||||
# info(f"Inline command ran by {update.message.chat.username}")
|
||||
log.info(f"Query: {update.inline_query.query}")
|
||||
|
||||
if not update.inline_query.query:
|
||||
return
|
||||
|
||||
print(f"Query: {update.inline_query.query}")
|
||||
|
||||
ignored_queries = {"$", "$$", " ", ""}
|
||||
|
||||
@ -443,7 +450,7 @@ def main():
|
||||
application.add_error_handler(error)
|
||||
|
||||
# Start the Bot
|
||||
application.run_polling()
|
||||
application.run_polling(allowed_updates=Update.ALL_TYPES)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user