aboutsummaryrefslogtreecommitdiff
path: root/matrix-redact.py
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-redact.py')
-rw-r--r--matrix-redact.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/matrix-redact.py b/matrix-redact.py
index 39a83bc..788ce7d 100644
--- a/matrix-redact.py
+++ b/matrix-redact.py
@@ -15,13 +15,28 @@ from nio import(
AsyncClient,
MatrixRoom,
LoginResponse,
+ RoomInfo,
responses
)
from typing import Optional
-# TODO: select_room
async def select_room(client: AsyncClient, sync_response) -> MatrixRoom:
+ rooms = []
+ for room_id, room in client.rooms.items():
+ if room_id in sync_response.rooms.join:
+ rooms.append({
+ "room_id": room_id,
+ "display_name": room.display_name,
+ })
+ print(f"{rooms[-1]['room_id']} | {rooms[-1]['display_name']}")
+
+ selection = input("\nManually type the full room ID to which redaction will be performed: ")
+ for room in rooms:
+ if room['room_id'] == selection:
+ print(f"{selection} will be redacted")
+ return room
+ print(f"{selection} is invalid. ")
return None
async def client_login() -> Optional[AsyncClient]:
@@ -81,7 +96,10 @@ async def main(args) -> None:
sys.exit(1)
sync_resp = await client.sync(timeout=30000, full_state=True)
- room = select_room(client, sync_resp)
+ room = await select_room(client, sync_resp)
+
+ if not room:
+ sys.exit(1)
except Exception as e:
print(f"Error: {e}")