From 6b26687fe011290355679c9dc0522b5074d02930 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 15 Aug 2017 05:48:56 +0300 Subject: [PATCH] Oops. Fix error message cleaner. (In past it can strip first symbol in message) --- aiogram/utils/exceptions.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aiogram/utils/exceptions.py b/aiogram/utils/exceptions.py index fdc18bb6..4a14f914 100644 --- a/aiogram/utils/exceptions.py +++ b/aiogram/utils/exceptions.py @@ -1,9 +1,11 @@ +_PREFIXES = ['Error: ', '[Error]: ', 'Bad Request: '] + + def _clean_message(text): - return text. \ - lstrip('Error: '). \ - lstrip('[Error]: '). \ - lstrip('Bad Request: '). \ - capitalize() + for prefix in _PREFIXES: + if text.startswith(prefix): + text = text[len(prefix):] + return text class TelegramAPIError(Exception):