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:
parent
edefc57147
commit
aec1391b17
2 changed files with 5 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
@ -13,4 +13,6 @@ is_template = yes
|
|||
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
|
||||
conversation_timeout = 7200
|
||||
; Time to wait before sending another getUpdates request
|
||||
long_polling_timeout = 30
|
5
core.py
5
core.py
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue