Skip to content

Commit 61dac76

Browse files
committed
don't send network_delay to telegram servers
1 parent 245f5ab commit 61dac76

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

telegram/bot.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ def getUpdates(self,
650650
offset=None,
651651
limit=100,
652652
timeout=0,
653-
network_delay=2):
653+
network_delay=2.):
654654
"""Use this method to receive incoming updates using long polling.
655655
656656
Args:
@@ -685,10 +685,8 @@ def getUpdates(self,
685685
data['limit'] = limit
686686
if timeout:
687687
data['timeout'] = timeout
688-
if network_delay:
689-
data['network_delay'] = network_delay
690688

691-
result = request.post(url, data)
689+
result = request.post(url, data, network_delay=network_delay)
692690

693691
if result:
694692
self.logger.info(

telegram/utils/request.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ def get(url):
6767

6868

6969
def post(url,
70-
data):
70+
data,
71+
network_delay=2.):
7172
"""Request an URL.
7273
Args:
7374
url:
7475
The web location we want to retrieve.
7576
data:
7677
A dict of (str, unicode) key/value pairs.
78+
network_delay:
79+
Additional timeout in seconds to allow the response from Telegram to
80+
take some time.
7781
7882
Returns:
7983
A JSON object.
@@ -82,10 +86,10 @@ def post(url,
8286
# Add time to the timeout of urlopen to allow data to be transferred over
8387
# the network.
8488
if 'timeout' in data:
85-
if 'network_delay' in data:
86-
timeout = data['timeout'] + data['network_delay']
89+
if network_delay:
90+
timeout = data['timeout'] + network_delay
8791
else:
88-
timeout = data['timeout'] + 2.
92+
timeout = data['timeout']
8993
else:
9094
timeout = None
9195

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy