mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-25 16:22:19 +01:00
Make telegram message sent by the error handler example more readable
This commit is contained in:
parent
d3afa8def2
commit
37230843dd
1 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
This is a very simple example on how one could implement a custom error handler
|
This is a very simple example on how one could implement a custom error handler
|
||||||
"""
|
"""
|
||||||
import html
|
import html
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ def error_handler(update: Update, context: CallbackContext):
|
||||||
'<pre>context.user_data = {}</pre>\n\n'
|
'<pre>context.user_data = {}</pre>\n\n'
|
||||||
'<pre>{}</pre>'
|
'<pre>{}</pre>'
|
||||||
).format(
|
).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.chat_data)),
|
||||||
html.escape(str(context.user_data)),
|
html.escape(str(context.user_data)),
|
||||||
html.escape(tb)
|
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)
|
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."""
|
"""Raise an error to trigger the error handler."""
|
||||||
context.bot.wrong_method_name()
|
context.bot.wrong_method_name()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue