Skip to content

Commit c9c0ee7

Browse files
committed
added connectionerror handler
1 parent 1bdcef1 commit c9c0ee7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

messageHandler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
if not TOKEN:
1313
logging.error("Error occurred, have you filled the token.txt file with your bot token?")
1414
exit()
15+
1516
URL = "https://api.telegram.org/bot{}/".format(TOKEN)
1617

1718

@@ -23,8 +24,12 @@ def __init__(self):
2324

2425
#
2526
def get_url(self, url):
26-
response = requests.get(url)
27-
content = response.content.decode("utf8")
27+
try:
28+
response = requests.get(url)
29+
content = response.content.decode("utf8")
30+
except requests.exceptions.ConnectionError:
31+
logging.info("Max retries exceed")
32+
content = ""
2833
return content
2934

3035
#

0 commit comments

Comments
 (0)