diff --git a/telegram_inference_bot.py b/telegram_inference_bot.py index 9aeb7e8..64d64b1 100644 --- a/telegram_inference_bot.py +++ b/telegram_inference_bot.py @@ -20,21 +20,21 @@ GPT_4O = "gpt-4o" GPT_4O_MINI = "gpt-4o-mini" class StringFilter(logging.Filter): - def __init__(self, string_to_filter): + def __init__(self, strings_to_filter): super().__init__() - self.string_to_filter = string_to_filter + self.strings_to_filter = strings_to_filter def filter(self, record): - return self.string_to_filter not in record.getMessage() + return not any(string in record.getMessage() for string in self.strings_to_filter) -string_to_filter = 'unwanted_string' # Change this to the specific string you want to filter out +unwanted_strings = ['unwanted_string1', 'unwanted_string2'] # Add other strings you want to filter out here # Set up logging to console and file logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler('logs/output.log', mode='a') ]) -logging.getLogger().addFilter(StringFilter(string_to_filter)) +logging.getLogger().addFilter(StringFilter(unwanted_strings)) # Set up Telegram bot TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN')