Merge 2f8c5a2e0b into 4583f88626
This commit is contained in:
commit
a6dd79228e
@ -1,3 +1,6 @@
|
|||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import process from "node:process";
|
||||||
import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js";
|
import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js";
|
||||||
import { getChannelPlugin, normalizeChannelId } from "../channels/plugins/index.js";
|
import { getChannelPlugin, normalizeChannelId } from "../channels/plugins/index.js";
|
||||||
import { DEFAULT_CHAT_CHANNEL } from "../channels/registry.js";
|
import { DEFAULT_CHAT_CHANNEL } from "../channels/registry.js";
|
||||||
@ -11,6 +14,18 @@ type ChannelAuthOptions = {
|
|||||||
verbose?: boolean;
|
verbose?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkDisabledPlugin = (channelInput: string) => {
|
||||||
|
try {
|
||||||
|
const extPath = path.join(process.cwd(), "extensions", channelInput);
|
||||||
|
if (fs.existsSync(extPath) && fs.statSync(extPath).isDirectory()) {
|
||||||
|
return `Channel '${channelInput}' plugin found but likely disabled. Run 'clawdbot plugins enable ${channelInput}' to use it.`;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return `Unsupported channel: ${channelInput}`;
|
||||||
|
};
|
||||||
|
|
||||||
export async function runChannelLogin(
|
export async function runChannelLogin(
|
||||||
opts: ChannelAuthOptions,
|
opts: ChannelAuthOptions,
|
||||||
runtime: RuntimeEnv = defaultRuntime,
|
runtime: RuntimeEnv = defaultRuntime,
|
||||||
@ -18,7 +33,7 @@ export async function runChannelLogin(
|
|||||||
const channelInput = opts.channel ?? DEFAULT_CHAT_CHANNEL;
|
const channelInput = opts.channel ?? DEFAULT_CHAT_CHANNEL;
|
||||||
const channelId = normalizeChannelId(channelInput);
|
const channelId = normalizeChannelId(channelInput);
|
||||||
if (!channelId) {
|
if (!channelId) {
|
||||||
throw new Error(`Unsupported channel: ${channelInput}`);
|
throw new Error(checkDisabledPlugin(channelInput));
|
||||||
}
|
}
|
||||||
const plugin = getChannelPlugin(channelId);
|
const plugin = getChannelPlugin(channelId);
|
||||||
if (!plugin?.auth?.login) {
|
if (!plugin?.auth?.login) {
|
||||||
@ -44,7 +59,7 @@ export async function runChannelLogout(
|
|||||||
const channelInput = opts.channel ?? DEFAULT_CHAT_CHANNEL;
|
const channelInput = opts.channel ?? DEFAULT_CHAT_CHANNEL;
|
||||||
const channelId = normalizeChannelId(channelInput);
|
const channelId = normalizeChannelId(channelInput);
|
||||||
if (!channelId) {
|
if (!channelId) {
|
||||||
throw new Error(`Unsupported channel: ${channelInput}`);
|
throw new Error(checkDisabledPlugin(channelInput));
|
||||||
}
|
}
|
||||||
const plugin = getChannelPlugin(channelId);
|
const plugin = getChannelPlugin(channelId);
|
||||||
if (!plugin?.gateway?.logoutAccount) {
|
if (!plugin?.gateway?.logoutAccount) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user