From d97c4b785d6d9c46453480b1d3df4de4a9760739 Mon Sep 17 00:00:00 2001 From: "15219900+Ninjagod1251@users.noreply.github.com" <15219900+Ninjagod1251@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:55:30 -0700 Subject: [PATCH] fix: error handler --- bot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 807baf9..5c49baf 100644 --- a/bot.py +++ b/bot.py @@ -6,6 +6,7 @@ from telegram.ext import Updater, CommandHandler, CallbackContext, MessageHandler, Filters import requests import anthropic +import logging # Load your OpenAI API key and Telegram token from environment variables or direct string assignment @@ -226,7 +227,10 @@ def handle_message(update: Update, context: CallbackContext) -> None: groups[group_id]['messages_today'] += 1 save_data() except Exception as e: - context.logger.error(f"Claude Error: {e}") + error_message = "f'Error message:' {e}" + update.message.reply_text(error_message) + + print(error_message)