support unencrypted rooms too
This commit is contained in:
parent
8cbdd0b2d8
commit
9b1199aff0
@ -13,7 +13,16 @@ room_id = sys.argv[1]
|
||||
sleep_for_seconds = 3
|
||||
|
||||
|
||||
def whoami(acces_token):
|
||||
headers = { "Authorization": f"Bearer {access_token}" }
|
||||
url = f"https://{homeserver}/_matrix/client/v3/account/whoami"
|
||||
response = requests.get(url, headers=headers)
|
||||
return response.json()['user_id']
|
||||
|
||||
|
||||
def get_all_encrypted_messages(homeserver, room_id, access_token):
|
||||
my_username = whoami(access_token)
|
||||
print("My user:", my_username)
|
||||
messages = []
|
||||
next_batch = None
|
||||
while True:
|
||||
@ -23,14 +32,13 @@ def get_all_encrypted_messages(homeserver, room_id, access_token):
|
||||
params = {
|
||||
"dir": "b",
|
||||
"limit": 50,
|
||||
"filter": '{"types": ["m.room.encrypted"]}'
|
||||
"filter": '{"senders":["' + my_username + '"]}'
|
||||
# "filter": '{"types":["m.room.encrypted"]}'
|
||||
}
|
||||
if next_batch:
|
||||
params["from"] = next_batch
|
||||
url = f"https://{homeserver}/_matrix/client/v3/rooms/{room_id}/messages"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {access_token}"
|
||||
}
|
||||
headers = { "Authorization": f"Bearer {access_token}" }
|
||||
response = requests.get(url, params=params, headers=headers)
|
||||
response.raise_for_status()
|
||||
chunk = response.json()["chunk"]
|
||||
|
Loading…
Reference in New Issue
Block a user