avoid rate limit
This commit is contained in:
parent
a909611995
commit
60c24972ca
@ -2,6 +2,7 @@
|
|||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
# configure your session here
|
# configure your session here
|
||||||
@ -9,6 +10,7 @@ homeserver = "matrix.thisisjoes.site"
|
|||||||
access_token = "syt_M4dpAzM_iQdfTcDDoiGhlOTDnz1r_5HfPcV"
|
access_token = "syt_M4dpAzM_iQdfTcDDoiGhlOTDnz1r_5HfPcV"
|
||||||
|
|
||||||
room_id = sys.argv[1]
|
room_id = sys.argv[1]
|
||||||
|
sleep_for_seconds = 3
|
||||||
|
|
||||||
|
|
||||||
def get_all_encrypted_messages(homeserver, room_id, access_token):
|
def get_all_encrypted_messages(homeserver, room_id, access_token):
|
||||||
@ -16,6 +18,7 @@ def get_all_encrypted_messages(homeserver, room_id, access_token):
|
|||||||
next_batch = None
|
next_batch = None
|
||||||
while True:
|
while True:
|
||||||
print("Reading messages...")
|
print("Reading messages...")
|
||||||
|
sleep(sleep_for_seconds)
|
||||||
params = {
|
params = {
|
||||||
"dir": "b",
|
"dir": "b",
|
||||||
"limit": 50,
|
"limit": 50,
|
||||||
@ -52,6 +55,8 @@ def redact_message(message):
|
|||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {access_token}"
|
"Authorization": f"Bearer {access_token}"
|
||||||
}
|
}
|
||||||
|
# don't get throtled
|
||||||
|
sleep(sleep_for_seconds)
|
||||||
response = requests.put(url, json={"reason":""}, headers=headers)
|
response = requests.put(url, json={"reason":""}, headers=headers)
|
||||||
print(pformat(response))
|
print(pformat(response))
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
Loading…
Reference in New Issue
Block a user