X Tutup
Skip to content

Commit 41eb459

Browse files
committed
use long polling in examples
1 parent 3658b42 commit 41eb459

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The following wonderful people contributed directly or indirectly to this projec
1414
- `JASON0916 <https://github.com/JASON0916>`_
1515
- `JRoot3D <https://github.com/JRoot3D>`_
1616
- `macrojames <https://github.com/macrojames>`_
17+
- `Rahiel Kasim <https://github.com/rahiel>`_
1718
- `sooyhwang <https://github.com/sooyhwang>`_
1819
- `wjt <https://github.com/wjt>`_
1920

examples/echobot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import logging
2121
import telegram
22-
import time
2322

2423

2524
LAST_UPDATE_ID = None
@@ -43,14 +42,13 @@ def main():
4342

4443
while True:
4544
echo(bot)
46-
time.sleep(3)
4745

4846

4947
def echo(bot):
5048
global LAST_UPDATE_ID
5149

5250
# Request updates after the last updated_id
53-
for update in bot.getUpdates(offset=LAST_UPDATE_ID):
51+
for update in bot.getUpdates(offset=LAST_UPDATE_ID, timeout=10):
5452
# chat_id is required to reply any message
5553
chat_id = update.message.chat_id
5654
message = update.message.text.encode('utf-8')

examples/roboed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main():
3333
LAST_UPDATE_ID = bot.getUpdates()[-1].update_id # Get lastest update
3434

3535
while True:
36-
for update in bot.getUpdates(offset=LAST_UPDATE_ID):
36+
for update in bot.getUpdates(offset=LAST_UPDATE_ID, timeout=10):
3737
text = update.message.text
3838
chat_id = update.message.chat.id
3939
update_id = update.update_id

0 commit comments

Comments
 (0)
X Tutup