1
1
#!/usr/bin/env python
2
- # pylint: disable=no-name-in-module,unused-import
3
2
#
4
3
# A library that provides a Python interface to the Telegram Bot API
5
4
# Copyright (C) 2015-2016
25
24
import socket
26
25
from ssl import SSLError
27
26
28
- try :
29
- # python2
30
- from httplib import HTTPException
31
- except ImportError :
32
- # python3
33
- from http .client import HTTPException
34
-
35
- try :
36
- # python3
37
- from urllib .request import urlopen , urlretrieve , Request
38
- from urllib .error import HTTPError , URLError
39
- except ImportError :
40
- # python2
41
- from urllib import urlretrieve
42
- from urllib2 import urlopen , Request , URLError
43
- from urllib2 import HTTPError
27
+ from future .moves .http .client import HTTPException
28
+ from future .moves .urllib .error import HTTPError , URLError
29
+ from future .moves .urllib .request import urlopen , urlretrieve , Request
44
30
45
31
from telegram import (InputFile , TelegramError )
46
32
from telegram .error import Unauthorized , NetworkError , TimedOut
@@ -130,8 +116,7 @@ def get(url):
130
116
@_try_except_req
131
117
def post (url ,
132
118
data ,
133
- timeout = None ,
134
- network_delay = 2. ):
119
+ timeout = None ):
135
120
"""Request an URL.
136
121
Args:
137
122
url:
@@ -141,11 +126,6 @@ def post(url,
141
126
timeout:
142
127
float. If this value is specified, use it as the definitive timeout (in
143
128
seconds) for urlopen() operations. [Optional]
144
- network_delay:
145
- float. If using the timeout specified in `data` (which is a timeout for
146
- the Telegram servers operation), then `network_delay` as an extra delay
147
- (in seconds) to compensate for network latency.
148
- default: 2 [Optional]
149
129
150
130
Notes:
151
131
If neither `timeout` nor `data['timeout']` is specified. The underlying
@@ -159,8 +139,6 @@ def post(url,
159
139
160
140
if timeout is not None :
161
141
urlopen_kwargs ['timeout' ] = timeout
162
- elif 'timeout' in data :
163
- urlopen_kwargs ['timeout' ] = data ['timeout' ] + network_delay
164
142
165
143
if InputFile .is_inputfile (data ):
166
144
data = InputFile (data )
0 commit comments