Skip to content

Commit 3a9dd63

Browse files
committed
Don't extract bot id in Conflict exception per PR comments
1 parent 00d9c7f commit 3a9dd63

3 files changed

Lines changed: 4 additions & 13 deletions

File tree

telegram/error.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# You should have received a copy of the GNU Lesser Public License
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains an object that represents Telegram errors."""
20-
import re
2120

2221

2322
def _lstrip_str(in_s, lstr):
@@ -107,15 +106,8 @@ class Conflict(TelegramError):
107106
108107
Args:
109108
msg (:obj:`str`): The message from telegrams server.
110-
url (:obj:`str`) The url used to make the request. The bot id will be extracted from
111-
it if possible.
112109
113110
"""
114-
def __init__(self, msg, url):
115-
# Get the bot token from the URL that was used to make the request
116-
# Regex simply searches for id in https://api.telegram.org/botID:TOKEN/method
117-
match = re.search(r'bot(\d+):.*/', url)
118-
if match:
119-
msg += '. Conflicting bot id: {}'.format(match.group(1))
120111

112+
def __init__(self, msg):
121113
super(Conflict, self).__init__(msg)

telegram/utils/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def _request_wrapper(self, *args, **kwargs):
224224
elif resp.status == 404:
225225
raise InvalidToken()
226226
elif resp.status == 409:
227-
raise Conflict(message, args[1])
227+
raise Conflict(message)
228228
elif resp.status == 413:
229229
raise NetworkError('File too large. Check telegram api limits '
230230
'https://core.telegram.org/bots/api#senddocument')

tests/test_error.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,5 @@ def test_retry_after(self):
8585
raise RetryAfter(12)
8686

8787
def test_conflict(self):
88-
with pytest.raises(Conflict, match=""):
89-
raise Conflict('Something something.',
90-
'https://api.telegram.org/bot1234567:ABCABCABCABC/sendMessage')
88+
with pytest.raises(Conflict, match='Something something.'):
89+
raise Conflict('Something something.')

0 commit comments

Comments
 (0)