Manages active Matrix bot SDK clients with multi-account support. Reuse when building multi-account Matrix chat integrations.
// Source: https://github.com/Yapie0/safe-openclaw | License: MIT | Copyright 2025 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
import type { MatrixClient } from "@vector-im/matrix-bot-sdk";
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
// Support multiple active clients for multi-account
const activeClients = new Map<string, MatrixClient>();
export function setActiveMatrixClient(
client: MatrixClient | null,
accountId?: string | null,
): void {
const key = normalizeAccountId(accountId);
if (client) {
activeClients.set(key, client);
} else {
activeClients.delete(key);
}
}
export function getActiveMatrixClient(accountId?: string | null): MatrixClient | null {
const key = normalizeAccountId(accountId);
re
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key