mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:58:26 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -8,11 +8,11 @@ import {
|
||||
type ChannelOnboardingAdapter,
|
||||
type ChannelOnboardingDmPolicy,
|
||||
type WizardPrompter,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
} from "openclaw/plugin-sdk";
|
||||
import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js";
|
||||
import { isAccountConfigured } from "./utils/twitch.js";
|
||||
import type { TwitchAccountConfig, TwitchRole } from "./types.js";
|
||||
import type { MoltbotConfig } from "clawdbot/plugin-sdk";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk";
|
||||
|
||||
const channel = "twitch" as const;
|
||||
|
||||
@@ -20,9 +20,9 @@ const channel = "twitch" as const;
|
||||
* Set Twitch account configuration
|
||||
*/
|
||||
function setTwitchAccount(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
account: Partial<TwitchAccountConfig>,
|
||||
): MoltbotConfig {
|
||||
): OpenClawConfig {
|
||||
const existing = getAccountConfig(cfg, DEFAULT_ACCOUNT_ID);
|
||||
const merged: TwitchAccountConfig = {
|
||||
username: account.username ?? existing?.username ?? "",
|
||||
@@ -70,7 +70,7 @@ async function noteTwitchSetupHelp(prompter: WizardPrompter): Promise<void> {
|
||||
"2. Generate a token with scopes: chat:read and chat:write",
|
||||
" Use https://twitchtokengenerator.com/ or https://twitchapps.com/tmi/",
|
||||
"3. Copy the token (starts with 'oauth:') and Client ID",
|
||||
"Env vars supported: CLAWDBOT_TWITCH_ACCESS_TOKEN",
|
||||
"Env vars supported: OPENCLAW_TWITCH_ACCESS_TOKEN",
|
||||
`Docs: ${formatDocsLink("/channels/twitch", "channels/twitch")}`,
|
||||
].join("\n"),
|
||||
"Twitch setup",
|
||||
@@ -205,15 +205,15 @@ async function promptRefreshTokenSetup(
|
||||
* Configure with env token path (returns early if user chooses env token).
|
||||
*/
|
||||
async function configureWithEnvToken(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
prompter: WizardPrompter,
|
||||
account: TwitchAccountConfig | null,
|
||||
envToken: string,
|
||||
forceAllowFrom: boolean,
|
||||
dmPolicy: ChannelOnboardingDmPolicy,
|
||||
): Promise<{ cfg: MoltbotConfig } | null> {
|
||||
): Promise<{ cfg: OpenClawConfig } | null> {
|
||||
const useEnv = await prompter.confirm({
|
||||
message: "Twitch env var CLAWDBOT_TWITCH_ACCESS_TOKEN detected. Use env token?",
|
||||
message: "Twitch env var OPENCLAW_TWITCH_ACCESS_TOKEN detected. Use env token?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (!useEnv) {
|
||||
@@ -241,10 +241,10 @@ async function configureWithEnvToken(
|
||||
* Set Twitch access control (role-based)
|
||||
*/
|
||||
function setTwitchAccessControl(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
allowedRoles: TwitchRole[],
|
||||
requireMention: boolean,
|
||||
): MoltbotConfig {
|
||||
): OpenClawConfig {
|
||||
const account = getAccountConfig(cfg, DEFAULT_ACCOUNT_ID);
|
||||
if (!account) {
|
||||
return cfg;
|
||||
@@ -272,7 +272,7 @@ const dmPolicy: ChannelOnboardingDmPolicy = {
|
||||
setPolicy: (cfg, policy) => {
|
||||
const allowedRoles: TwitchRole[] =
|
||||
policy === "open" ? ["all"] : policy === "allowlist" ? [] : ["moderator"];
|
||||
return setTwitchAccessControl(cfg as MoltbotConfig, allowedRoles, true);
|
||||
return setTwitchAccessControl(cfg as OpenClawConfig, allowedRoles, true);
|
||||
},
|
||||
promptAllowFrom: async ({ cfg, prompter }) => {
|
||||
const account = getAccountConfig(cfg, DEFAULT_ACCOUNT_ID);
|
||||
@@ -289,7 +289,7 @@ const dmPolicy: ChannelOnboardingDmPolicy = {
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
return setTwitchAccount(cfg as MoltbotConfig, {
|
||||
return setTwitchAccount(cfg as OpenClawConfig, {
|
||||
...(account ?? undefined),
|
||||
allowFrom,
|
||||
});
|
||||
@@ -316,7 +316,7 @@ export const twitchOnboardingAdapter: ChannelOnboardingAdapter = {
|
||||
await noteTwitchSetupHelp(prompter);
|
||||
}
|
||||
|
||||
const envToken = process.env.CLAWDBOT_TWITCH_ACCESS_TOKEN?.trim();
|
||||
const envToken = process.env.OPENCLAW_TWITCH_ACCESS_TOKEN?.trim();
|
||||
|
||||
// Check if env var is set and config is empty
|
||||
if (envToken && !account?.accessToken) {
|
||||
|
||||
Reference in New Issue
Block a user