diff --git a/common/symbol_router.py b/common/symbol_router.py index c322925..c0ec4ca 100644 --- a/common/symbol_router.py +++ b/common/symbol_router.py @@ -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}" diff --git a/telegram/bot.py b/telegram/bot.py index 7829fa4..fd7fd6c 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -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__":