mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:10:51 +00:00
Twitch: add bundled setup entry
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"extensions": [
|
||||
"./index.ts"
|
||||
],
|
||||
"setupEntry": "./setup-entry.ts",
|
||||
"install": {
|
||||
"minHostVersion": ">=2026.4.10"
|
||||
},
|
||||
|
||||
9
extensions/twitch/setup-entry.ts
Normal file
9
extensions/twitch/setup-entry.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
||||
|
||||
export default defineBundledChannelSetupEntry({
|
||||
importMetaUrl: import.meta.url,
|
||||
plugin: {
|
||||
specifier: "./src/setup-surface.js",
|
||||
exportName: "twitchSetupPlugin",
|
||||
},
|
||||
});
|
||||
@@ -2,6 +2,7 @@
|
||||
* Twitch setup wizard surface for CLI setup.
|
||||
*/
|
||||
|
||||
import { getChatChannelMeta, type ChannelPlugin } from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
formatDocsLink,
|
||||
type ChannelSetupAdapter,
|
||||
@@ -426,3 +427,37 @@ export const twitchSetupWizard: ChannelSetupWizard = {
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
type ResolvedTwitchAccount = TwitchAccountConfig & { accountId?: string | null };
|
||||
|
||||
export const twitchSetupPlugin: ChannelPlugin<ResolvedTwitchAccount> = {
|
||||
id: channel,
|
||||
meta: getChatChannelMeta(channel),
|
||||
capabilities: {
|
||||
chatTypes: ["group"],
|
||||
},
|
||||
config: {
|
||||
listAccountIds: (cfg) => {
|
||||
const accountId = resolveSetupAccountId(cfg);
|
||||
return getAccountConfig(cfg, accountId) ? [accountId] : [];
|
||||
},
|
||||
resolveAccount: (cfg, accountId) => {
|
||||
const resolvedAccountId = accountId ?? resolveSetupAccountId(cfg);
|
||||
const account = getAccountConfig(cfg, resolvedAccountId);
|
||||
const fallback = {
|
||||
accountId: resolvedAccountId,
|
||||
username: "",
|
||||
accessToken: "",
|
||||
clientId: "",
|
||||
channel: "",
|
||||
enabled: false,
|
||||
};
|
||||
return account ? { ...fallback, ...account } : fallback;
|
||||
},
|
||||
defaultAccountId: (cfg) => resolveSetupAccountId(cfg),
|
||||
isConfigured: (account) => isAccountConfigured(account),
|
||||
isEnabled: (account) => account.enabled !== false,
|
||||
},
|
||||
setup: twitchSetupAdapter,
|
||||
setupWizard: twitchSetupWizard,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user