Search... Ctrl + K

Get entire room state (matrix)
One script reply has been approved by the moderators Verified

Created by jaller94 113 days ago Used 19 times 1 Point

Given a room, this returns an array of all current state events.

No comments yet

Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved
import * as wmill from "https://deno.land/x/windmill@v1.35.0/mod.ts";

export async function main(matrix_res: wmill.Resource<"matrix">, room_id: string) {
  const url = `${matrix_res.baseUrl}/_matrix/client/v3/rooms/${encodeURIComponent(room_id)}/state`;
  const resp = await fetch(url, {
    headers: {
      "Authorization": `Bearer ${matrix_res.token}`,
    },
  });
  if (!resp.ok) {
    throw Error(`Failed to read room state: Error HTTP${resp.status}`);
  }
  return {
    events: await resp.json(),
  };
}

Submitted by jaller94 63 days ago

Edited 61 days ago

No comments yet