mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 15:17:00 +01:00
commit
2f99b785b2
3 changed files with 3 additions and 4 deletions
|
@ -14,6 +14,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||||
- `JASON0916 <https://github.com/JASON0916>`_
|
- `JASON0916 <https://github.com/JASON0916>`_
|
||||||
- `JRoot3D <https://github.com/JRoot3D>`_
|
- `JRoot3D <https://github.com/JRoot3D>`_
|
||||||
- `macrojames <https://github.com/macrojames>`_
|
- `macrojames <https://github.com/macrojames>`_
|
||||||
|
- `Rahiel Kasim <https://github.com/rahiel>`_
|
||||||
- `sooyhwang <https://github.com/sooyhwang>`_
|
- `sooyhwang <https://github.com/sooyhwang>`_
|
||||||
- `wjt <https://github.com/wjt>`_
|
- `wjt <https://github.com/wjt>`_
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import telegram
|
import telegram
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
LAST_UPDATE_ID = None
|
LAST_UPDATE_ID = None
|
||||||
|
@ -43,14 +42,13 @@ def main():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
echo(bot)
|
echo(bot)
|
||||||
time.sleep(3)
|
|
||||||
|
|
||||||
|
|
||||||
def echo(bot):
|
def echo(bot):
|
||||||
global LAST_UPDATE_ID
|
global LAST_UPDATE_ID
|
||||||
|
|
||||||
# Request updates after the last updated_id
|
# Request updates after the last updated_id
|
||||||
for update in bot.getUpdates(offset=LAST_UPDATE_ID):
|
for update in bot.getUpdates(offset=LAST_UPDATE_ID, timeout=10):
|
||||||
# chat_id is required to reply any message
|
# chat_id is required to reply any message
|
||||||
chat_id = update.message.chat_id
|
chat_id = update.message.chat_id
|
||||||
message = update.message.text.encode('utf-8')
|
message = update.message.text.encode('utf-8')
|
||||||
|
|
|
@ -33,7 +33,7 @@ def main():
|
||||||
LAST_UPDATE_ID = bot.getUpdates()[-1].update_id # Get lastest update
|
LAST_UPDATE_ID = bot.getUpdates()[-1].update_id # Get lastest update
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for update in bot.getUpdates(offset=LAST_UPDATE_ID):
|
for update in bot.getUpdates(offset=LAST_UPDATE_ID, timeout=10):
|
||||||
text = update.message.text
|
text = update.message.text
|
||||||
chat_id = update.message.chat.id
|
chat_id = update.message.chat.id
|
||||||
update_id = update.update_id
|
update_id = update.update_id
|
||||||
|
|
Loading…
Reference in a new issue