Skip to content

Commit 2fb0f3f

Browse files
authored
Merge pull request eternnoir#684 from xxsokolov/patch-1
Update apihelper.py
2 parents c6358f3 + 575fb9d commit 2fb0f3f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

telebot/apihelper.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
logger = telebot.logger
2121
proxy = None
2222

23-
API_URL = "https://api.telegram.org/bot{0}/{1}"
24-
FILE_URL = "https://api.telegram.org/file/bot{0}/{1}"
23+
API_URL = None
24+
FILE_URL = None
2525

2626
CONNECT_TIMEOUT = 3.5
2727
READ_TIMEOUT = 9999
@@ -41,6 +41,11 @@ def _make_request(token, method_name, method='get', params=None, files=None, bas
4141
:param files: Optional files.
4242
:return: The result parsed to a JSON dictionary.
4343
"""
44+
if base_url is None:
45+
request_url = "https://api.telegram.org/bot{0}/{1}".format(token, method_name)
46+
else:
47+
request_url = base_url.format(token, method_name)
48+
4449
request_url = base_url.format(token, method_name)
4550
logger.debug("Request: method={0} url={1} params={2} files={3}".format(method, request_url, params, files))
4651
read_timeout = READ_TIMEOUT
@@ -99,8 +104,11 @@ def get_file(token, file_id):
99104

100105

101106
def get_file_url(token, file_id):
102-
return FILE_URL.format(token, get_file(token, file_id)['file_path'])
103-
107+
if FILE_URL is None:
108+
return "https://api.telegram.org/file/bot{0}/{1}".format(token, get_file(token, file_id).file_path)
109+
else:
110+
return FILE_URL.format(token, get_file(token, file_id)['file_path'])
111+
104112

105113
def download_file(token, file_path):
106114
url = FILE_URL.format(token, file_path)

0 commit comments

Comments
 (0)