mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-05 05:51:42 +00:00
* refactor(channels)!: shrink ChannelSetupInput to a generic envelope with a deprecated compatibility tier * fix(channels): keep ChannelSetupInput structurally assignable without an index signature * docs: regenerate docs map
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
// Googlechat plugin module implements setup core behavior.
|
|
import type { ChannelSetupInput } from "openclaw/plugin-sdk/channel-setup";
|
|
import {
|
|
createPatchedAccountSetupAdapter,
|
|
createSetupInputPresenceValidator,
|
|
} from "openclaw/plugin-sdk/setup-runtime";
|
|
|
|
const channel = "googlechat" as const;
|
|
|
|
type GoogleChatSetupInput = ChannelSetupInput & {
|
|
audienceType?: string;
|
|
audience?: string;
|
|
webhookPath?: string;
|
|
webhookUrl?: string;
|
|
};
|
|
|
|
export const googlechatSetupAdapter = createPatchedAccountSetupAdapter({
|
|
channelKey: channel,
|
|
validateInput: createSetupInputPresenceValidator({
|
|
defaultAccountOnlyEnvError:
|
|
"GOOGLE_CHAT_SERVICE_ACCOUNT env vars can only be used for the default account.",
|
|
whenNotUseEnv: [
|
|
{
|
|
someOf: ["token", "tokenFile"],
|
|
message: "Google Chat requires --token (service account JSON) or --token-file.",
|
|
},
|
|
],
|
|
}),
|
|
buildPatch: (input) => {
|
|
const setupInput = input as GoogleChatSetupInput;
|
|
const patch = setupInput.useEnv
|
|
? {}
|
|
: setupInput.tokenFile
|
|
? { serviceAccountFile: setupInput.tokenFile }
|
|
: setupInput.token
|
|
? { serviceAccount: setupInput.token }
|
|
: {};
|
|
const audienceType = setupInput.audienceType?.trim();
|
|
const audience = setupInput.audience?.trim();
|
|
const webhookPath = setupInput.webhookPath?.trim();
|
|
const webhookUrl = setupInput.webhookUrl?.trim();
|
|
return {
|
|
...patch,
|
|
...(audienceType ? { audienceType } : {}),
|
|
...(audience ? { audience } : {}),
|
|
...(webhookPath ? { webhookPath } : {}),
|
|
...(webhookUrl ? { webhookUrl } : {}),
|
|
};
|
|
},
|
|
});
|