feat: add matrix channel plugin

This commit is contained in:
Peter Steinberger
2026-01-15 08:29:17 +00:00
parent f4bb5b381d
commit 725a6b71dc
51 changed files with 3986 additions and 24 deletions

View File

@@ -36,6 +36,12 @@ export function applyChannelAccountConfig(params: {
httpHost?: string;
httpPort?: string;
useEnv?: boolean;
homeserver?: string;
userId?: string;
accessToken?: string;
password?: string;
deviceName?: string;
initialSyncLimit?: number;
}): ClawdbotConfig {
const accountId = normalizeAccountId(params.accountId);
const plugin = getChannelPlugin(params.channel);
@@ -57,6 +63,12 @@ export function applyChannelAccountConfig(params: {
httpHost: params.httpHost,
httpPort: params.httpPort,
useEnv: params.useEnv,
homeserver: params.homeserver,
userId: params.userId,
accessToken: params.accessToken,
password: params.password,
deviceName: params.deviceName,
initialSyncLimit: params.initialSyncLimit,
};
return apply({ cfg: params.cfg, accountId, input });
}

View File

@@ -27,6 +27,12 @@ export type ChannelsAddOptions = {
httpHost?: string;
httpPort?: string;
useEnv?: boolean;
homeserver?: string;
userId?: string;
accessToken?: string;
password?: string;
deviceName?: string;
initialSyncLimit?: number | string;
};
export async function channelsAddCommand(
@@ -88,9 +94,9 @@ export async function channelsAddCommand(
}
await writeConfigFile(nextConfig);
await prompter.outro("Channels updated.");
return;
}
await prompter.outro("Channels updated.");
return;
}
const channel = normalizeChannelId(opts.channel);
if (!channel) {
@@ -109,6 +115,12 @@ export async function channelsAddCommand(
plugin.setup.resolveAccountId?.({ cfg, accountId: opts.account }) ??
normalizeAccountId(opts.account);
const useEnv = opts.useEnv === true;
const initialSyncLimit =
typeof opts.initialSyncLimit === "number"
? opts.initialSyncLimit
: typeof opts.initialSyncLimit === "string" && opts.initialSyncLimit.trim()
? Number.parseInt(opts.initialSyncLimit, 10)
: undefined;
const validationError = plugin.setup.validateInput?.({
cfg,
accountId,
@@ -127,6 +139,12 @@ export async function channelsAddCommand(
httpUrl: opts.httpUrl,
httpHost: opts.httpHost,
httpPort: opts.httpPort,
homeserver: opts.homeserver,
userId: opts.userId,
accessToken: opts.accessToken,
password: opts.password,
deviceName: opts.deviceName,
initialSyncLimit,
useEnv,
},
});
@@ -154,6 +172,12 @@ export async function channelsAddCommand(
httpUrl: opts.httpUrl,
httpHost: opts.httpHost,
httpPort: opts.httpPort,
homeserver: opts.homeserver,
userId: opts.userId,
accessToken: opts.accessToken,
password: opts.password,
deviceName: opts.deviceName,
initialSyncLimit,
useEnv,
});