From 37230843dd11688b80d75b640406097b2a3a2b60 Mon Sep 17 00:00:00 2001 From: n5y <41209360+n5y@users.noreply.github.com> Date: Wed, 10 Jun 2020 01:56:48 +0300 Subject: [PATCH] Make telegram message sent by the error handler example more readable --- examples/error_handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/error_handler.py b/examples/error_handler.py index 16c7aa384..31fd09da6 100644 --- a/examples/error_handler.py +++ b/examples/error_handler.py @@ -6,6 +6,7 @@ This is a very simple example on how one could implement a custom error handler """ import html +import json import logging import traceback @@ -40,7 +41,7 @@ def error_handler(update: Update, context: CallbackContext): '
context.user_data = {}\n\n' '
{}' ).format( - html.escape(update.to_json()), + html.escape(json.dumps(update.to_dict(), indent=2, ensure_ascii=False)), html.escape(str(context.chat_data)), html.escape(str(context.user_data)), html.escape(tb) @@ -50,7 +51,7 @@ def error_handler(update: Update, context: CallbackContext): context.bot.send_message(chat_id=DEVELOPER_CHAT_ID, text=message, parse_mode=ParseMode.HTML) -def bad_command(udpate: Update, context: CallbackContext): +def bad_command(update: Update, context: CallbackContext): """Raise an error to trigger the error handler.""" context.bot.wrong_method_name()