From 302b3a78bd7a61be877daa66f81d406189b7ef62 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 16 May 2021 15:18:48 +0300 Subject: don't send telegram.error.TimedOut to user --- inverter-bot | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'inverter-bot') diff --git a/inverter-bot b/inverter-bot index 921b185..b9937e4 100755 --- a/inverter-bot +++ b/inverter-bot @@ -21,6 +21,7 @@ from telegram.ext import ( MessageHandler, CallbackContext ) +from telegram.error import TimedOut class InverterClientWrapper: @@ -121,7 +122,8 @@ def msg_status(update: Update, context: CallbackContext) -> None: reply(update, html) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_generation(update: Update, context: CallbackContext) -> None: @@ -161,7 +163,8 @@ def msg_generation(update: Update, context: CallbackContext) -> None: reply(update, html) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_gs(update: Update, context: CallbackContext) -> None: @@ -170,7 +173,8 @@ def msg_gs(update: Update, context: CallbackContext) -> None: reply(update, status) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_ri(update: Update, context: CallbackContext) -> None: @@ -179,7 +183,8 @@ def msg_ri(update: Update, context: CallbackContext) -> None: reply(update, rated) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_errors(update: Update, context: CallbackContext) -> None: @@ -188,7 +193,8 @@ def msg_errors(update: Update, context: CallbackContext) -> None: reply(update, errors) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_all(update: Update, context: CallbackContext) -> None: -- cgit v1.2.3