1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-22 05:54:18 +00:00

Configure long polling

This commit is contained in:
Steffo 2017-12-14 10:25:05 +01:00
parent edefc57147
commit aec1391b17
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: C27544372FBB445D
2 changed files with 5 additions and 6 deletions

View file

@ -3,7 +3,7 @@
# Config file parameters
[Config]
; Config file version. DO NOT EDIT THIS!
version = 2
version = 3
; Set this to no when you are done editing the file
is_template = yes
@ -14,3 +14,5 @@ token = 123456789:YOUR_TOKEN_GOES_HERE_______________
; Time in seconds before a conversation with no new messages expires
; A lower value reduces memory usage but can be inconvenient for the users
conversation_timeout = 7200
; Time to wait before sending another getUpdates request
long_polling_timeout = 30

View file

@ -33,7 +33,7 @@ def main():
while True:
# Get a new batch of 100 updates and mark the last 100 parsed as read
# TODO: handle possible errors
updates = bot.get_updates(offset=next_update)
updates = bot.get_updates(offset=next_update, timeout=int(config["Telegram"]["long_polling_timeout"]))
# Parse all the updates
for update in updates:
# If the update is a message...
@ -85,9 +85,6 @@ def main():
if len(updates):
# Mark them as read by increasing the update_offset
next_update = updates[-1].update_id + 1
# Temporarily prevent rate limits
# TODO: (remove this later)
time.sleep(5)
# Run the main function only in the main process