From d1f722ff0d7ec237459c32e276221ad66337fe53 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sun, 25 Feb 2018 22:53:20 +0100 Subject: [PATCH] =?UTF-8?q?Verstecke=20"Error=20while=20getting=20Updates"?= =?UTF-8?q?=20und=20Logger-Fix=20f=C3=BCr=20Python=20<=3D=203.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bot.py b/bot.py index 88ae302..b9068bb 100644 --- a/bot.py +++ b/bot.py @@ -340,6 +340,10 @@ def run_job(bot, job=None): check_feed(bot, key) +def onerror(bot, update, error): + logger.error(error) + + # Main function def main(): # Setup the updater and show bot info @@ -364,6 +368,12 @@ def main(): for handler in handlers: updater.dispatcher.add_handler(handler) + # Hide "Error while getting Updates" because it's not our fault + updater.logger.addFilter((lambda log: not log.msg.startswith('Error while getting Updates:'))) + + # Fix for Python <= 3.5 + updater.dispatcher.add_error_handler(onerror) + updater.job_queue.run_repeating( run_job, interval=60.0,