File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818
1919"""This module contains a object that represents a Telegram Error"""
2020
21- import re
21+
22+ def _lstrip_str (in_s , lstr ):
23+ """
24+ Args:
25+ in_s (str): in string
26+ lstr (str): substr to strip from left side
27+
28+ Returns:
29+ str:
30+
31+ """
32+ if in_s .startswith (lstr ):
33+ res = in_s [len (lstr ):]
34+ else :
35+ res = in_s
36+ return res
2237
2338
2439class TelegramError (Exception ):
2540 """This object represents a Telegram Error."""
2641
2742 def __init__ (self , message ):
2843 """
44+ Args:
45+ message (str):
46+
2947 Returns:
30- str:
48+
3149 """
3250 super (TelegramError , self ).__init__ ()
3351
34- api_error = re .match (r'^Error: (?P<message>.*)' , message )
35- if api_error :
36- self .message = api_error .group ('message' ).capitalize ()
37- else :
38- self .message = message
52+ msg = _lstrip_str (message , 'Error: ' )
53+ msg = _lstrip_str (msg , '[Error]: ' )
54+ if msg != message :
55+ # api_error - capitalize the msg...
56+ msg = msg .capitalize ()
57+ self .message = msg
3958
4059 def __str__ (self ):
4160 return '%s' % (self .message )
You can’t perform that action at this time.
0 commit comments