Search... Ctrl + K

Join room (matrix)
One script reply has been approved by the moderators Verified

Created by jaller94 113 days ago Used 39 times 1 Point

Joins a Matrix room.

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.29.0/mod.ts";

export async function main(
	matrix_res: wmill.Resource<"matrix">,
	room: string,
) {
	if (!matrix_res.token) {
		throw Error("Joining a room requires an access token.");
	}
	const resp = await fetch(
		`${matrix_res.baseUrl}/_matrix/client/v3/join/${encodeURIComponent(room)}`,
		{
			method: "POST",
			headers: {
				"Authorization": `Bearer ${matrix_res.token}`,
            },
		},
	);
	if (!resp.ok) {
		throw Error(`Failed to join room: Error HTTP${resp.status}`);
	}
}

Submitted by jaller94 113 days ago

Edited 61 days ago

No comments yet