OpenClaw 完整备份 - 2026-03-21
This commit is contained in:
+137
@@ -0,0 +1,137 @@
|
||||
export { DEFAULT_ACCOUNT_ID as DINGTALK_DEFAULT_ACCOUNT_ID, DingtalkConfig, DingtalkSendResult, ResolvedDingtalkAccount, dingtalkPlugin, getDingtalkRuntime, sendMessageDingtalk, setDingtalkRuntime } from '@openclaw-china/dingtalk';
|
||||
export { DEFAULT_ACCOUNT_ID as FEISHU_DEFAULT_ACCOUNT_ID, FeishuConfig, FeishuSendResult, ResolvedFeishuAccount, feishuPlugin, getFeishuRuntime, sendMessageFeishu, setFeishuRuntime } from '@openclaw-china/feishu-china';
|
||||
export { ResolvedWecomAccount, DEFAULT_ACCOUNT_ID as WECOM_DEFAULT_ACCOUNT_ID, WecomConfig, WecomInboundMessage, getWecomRuntime, setWecomRuntime, wecomPlugin } from '@openclaw-china/wecom';
|
||||
export { AccessTokenCacheEntry, ResolvedWecomAppAccount, DEFAULT_ACCOUNT_ID as WECOM_APP_DEFAULT_ACCOUNT_ID, WecomAppConfig, WecomAppDmPolicy, WecomAppInboundMessage, WecomAppSendTarget, clearAccessTokenCache, clearAllAccessTokenCache, downloadAndSendImage, getAccessToken, getWecomAppRuntime, sendWecomAppImageMessage, sendWecomAppMarkdownMessage, sendWecomAppMessage, setWecomAppRuntime, stripMarkdown, wecomAppPlugin } from '@openclaw-china/wecom-app';
|
||||
export { ResolvedWecomKfAccount, DEFAULT_ACCOUNT_ID as WECOM_KF_DEFAULT_ACCOUNT_ID, WecomKfAccountConfig, WecomKfConfig, WecomKfDmPolicy, SyncMsgItem as WecomKfSyncMsgItem, SyncMsgResponse as WecomKfSyncMsgResponse, getWecomKfRuntime, setWecomKfRuntime, wecomKfPlugin } from '@openclaw-china/wecom-kf';
|
||||
export { DEFAULT_ACCOUNT_ID as QQBOT_DEFAULT_ACCOUNT_ID, QQBotConfig, QQBotSendResult, ResolvedQQBotAccount, getQQBotRuntime, qqbotPlugin, setQQBotRuntime } from '@openclaw-china/qqbot';
|
||||
|
||||
/**
|
||||
* @openclaw-china/channels
|
||||
* 统一渠道包入口
|
||||
*
|
||||
* 导出所有渠道插件,提供统一注册函数
|
||||
*
|
||||
* Requirements: Unified Package Entry, Unified Distribution
|
||||
*/
|
||||
|
||||
/**
|
||||
* 渠道配置接口
|
||||
*/
|
||||
interface ChannelConfig {
|
||||
/** 是否启用该渠道 */
|
||||
enabled?: boolean;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
interface WecomRouteConfig extends ChannelConfig {
|
||||
webhookPath?: string;
|
||||
accounts?: Record<string, {
|
||||
webhookPath?: string;
|
||||
}>;
|
||||
}
|
||||
interface WecomAppRouteConfig extends ChannelConfig {
|
||||
webhookPath?: string;
|
||||
accounts?: Record<string, {
|
||||
webhookPath?: string;
|
||||
}>;
|
||||
}
|
||||
interface WecomKfRouteConfig extends ChannelConfig {
|
||||
webhookPath?: string;
|
||||
accounts?: Record<string, {
|
||||
webhookPath?: string;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* Moltbot 配置接口(符合官方约定)
|
||||
* 配置路径: channels.<id>.enabled
|
||||
*/
|
||||
interface MoltbotConfig {
|
||||
channels?: {
|
||||
dingtalk?: ChannelConfig;
|
||||
"feishu-china"?: ChannelConfig;
|
||||
wecom?: WecomRouteConfig;
|
||||
"wecom-app"?: WecomAppRouteConfig;
|
||||
"wecom-kf"?: WecomKfRouteConfig;
|
||||
qqbot?: ChannelConfig;
|
||||
qq?: ChannelConfig;
|
||||
[key: string]: ChannelConfig | undefined;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Moltbot 插件 API 接口
|
||||
*/
|
||||
interface MoltbotPluginApi {
|
||||
registerChannel: (opts: {
|
||||
plugin: unknown;
|
||||
}) => void;
|
||||
registerCli?: (registrar: (ctx: {
|
||||
program: unknown;
|
||||
config?: MoltbotConfig;
|
||||
}) => void | Promise<void>, opts?: {
|
||||
commands?: string[];
|
||||
}) => void;
|
||||
logger?: {
|
||||
info?: (message: string) => void;
|
||||
warn?: (message: string) => void;
|
||||
error?: (message: string) => void;
|
||||
};
|
||||
runtime?: {
|
||||
config?: {
|
||||
writeConfigFile?: (cfg: unknown) => Promise<void>;
|
||||
};
|
||||
};
|
||||
config?: MoltbotConfig;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* 支持的渠道列表
|
||||
*/
|
||||
declare const SUPPORTED_CHANNELS: readonly ["dingtalk", "feishu-china", "wecom", "wecom-app", "wecom-kf", "qqbot"];
|
||||
type SupportedChannel = (typeof SUPPORTED_CHANNELS)[number];
|
||||
/**
|
||||
* 根据 Moltbot 配置注册启用的渠道
|
||||
*
|
||||
* 符合 Moltbot 官方约定:从 cfg.channels.<id>.enabled 读取配置
|
||||
*
|
||||
* @param api Moltbot 鎻掍欢 API
|
||||
* @param cfg Moltbot 配置(可选,默认从 api.config 读取)
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // moltbot.json 配置
|
||||
* {
|
||||
* "channels": {
|
||||
* "dingtalk": {
|
||||
* "enabled": true,
|
||||
* "clientId": "...",
|
||||
* "clientSecret": "..."
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function registerChannelsByConfig(api: MoltbotPluginApi, cfg?: MoltbotConfig): void;
|
||||
/**
|
||||
* 统一渠道插件定义
|
||||
*
|
||||
* 包含所有支持的渠道,通过配置启用
|
||||
* 配置路径符合 Moltbot 官方约定: channels.<id>
|
||||
*/
|
||||
declare const channelsPlugin: {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
configSchema: {
|
||||
type: string;
|
||||
additionalProperties: boolean;
|
||||
properties: {};
|
||||
};
|
||||
/**
|
||||
* 注册所有启用的渠道
|
||||
*
|
||||
* 从 api.config.channels.<id>.enabled 读取配置
|
||||
*/
|
||||
register(api: MoltbotPluginApi): void;
|
||||
};
|
||||
|
||||
export { type ChannelConfig, type MoltbotConfig, type MoltbotPluginApi, SUPPORTED_CHANNELS, type SupportedChannel, type WecomAppRouteConfig, type WecomKfRouteConfig, type WecomRouteConfig, channelsPlugin as default, registerChannelsByConfig };
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
import dingtalkEntry from '@openclaw-china/dingtalk';
|
||||
export { DEFAULT_ACCOUNT_ID as DINGTALK_DEFAULT_ACCOUNT_ID, dingtalkPlugin, getDingtalkRuntime, sendMessageDingtalk, setDingtalkRuntime } from '@openclaw-china/dingtalk';
|
||||
import feishuEntry from '@openclaw-china/feishu-china';
|
||||
export { DEFAULT_ACCOUNT_ID as FEISHU_DEFAULT_ACCOUNT_ID, feishuPlugin, getFeishuRuntime, sendMessageFeishu, setFeishuRuntime } from '@openclaw-china/feishu-china';
|
||||
import wecomEntry from '@openclaw-china/wecom';
|
||||
export { DEFAULT_ACCOUNT_ID as WECOM_DEFAULT_ACCOUNT_ID, getWecomRuntime, setWecomRuntime, wecomPlugin } from '@openclaw-china/wecom';
|
||||
import wecomAppEntry from '@openclaw-china/wecom-app';
|
||||
export { DEFAULT_ACCOUNT_ID as WECOM_APP_DEFAULT_ACCOUNT_ID, clearAccessTokenCache, clearAllAccessTokenCache, downloadAndSendImage, getAccessToken, getWecomAppRuntime, sendWecomAppImageMessage, sendWecomAppMarkdownMessage, sendWecomAppMessage, setWecomAppRuntime, stripMarkdown, wecomAppPlugin } from '@openclaw-china/wecom-app';
|
||||
import wecomKfEntry from '@openclaw-china/wecom-kf';
|
||||
export { DEFAULT_ACCOUNT_ID as WECOM_KF_DEFAULT_ACCOUNT_ID, getWecomKfRuntime, setWecomKfRuntime, wecomKfPlugin } from '@openclaw-china/wecom-kf';
|
||||
import qqbotEntry from '@openclaw-china/qqbot';
|
||||
export { DEFAULT_ACCOUNT_ID as QQBOT_DEFAULT_ACCOUNT_ID, getQQBotRuntime, qqbotPlugin, setQQBotRuntime } from '@openclaw-china/qqbot';
|
||||
import { registerChinaSetupCli, showChinaInstallHint } from '@openclaw-china/shared';
|
||||
|
||||
// src/index.ts
|
||||
var SUPPORTED_CHANNELS = ["dingtalk", "feishu-china", "wecom", "wecom-app", "wecom-kf", "qqbot"];
|
||||
var channelPlugins = {
|
||||
dingtalk: {
|
||||
register: (api) => {
|
||||
dingtalkEntry.register(api);
|
||||
}
|
||||
},
|
||||
"feishu-china": {
|
||||
register: (api) => {
|
||||
feishuEntry.register(api);
|
||||
}
|
||||
},
|
||||
wecom: {
|
||||
register: (api) => {
|
||||
wecomEntry.register(api);
|
||||
}
|
||||
},
|
||||
"wecom-app": {
|
||||
register: (api) => {
|
||||
wecomAppEntry.register(api);
|
||||
}
|
||||
},
|
||||
"wecom-kf": {
|
||||
register: (api) => {
|
||||
wecomKfEntry.register(api);
|
||||
}
|
||||
},
|
||||
qqbot: {
|
||||
register: (api) => {
|
||||
qqbotEntry.register(api);
|
||||
}
|
||||
}
|
||||
};
|
||||
function registerChannelsByConfig(api, cfg) {
|
||||
const config = cfg ?? api.config;
|
||||
const channelsConfig = config?.channels;
|
||||
if (!channelsConfig) {
|
||||
return;
|
||||
}
|
||||
for (const channelId of SUPPORTED_CHANNELS) {
|
||||
const channelConfig = channelsConfig[channelId];
|
||||
if (!channelConfig?.enabled) {
|
||||
continue;
|
||||
}
|
||||
const plugin = channelPlugins[channelId];
|
||||
plugin.register(api);
|
||||
}
|
||||
}
|
||||
var channelsPlugin = {
|
||||
id: "channels",
|
||||
name: "Moltbot China Channels",
|
||||
description: "\u7EDF\u4E00\u6E20\u9053\u5305\uFF0C\u652F\u6301\u9489\u9489\u3001\u98DE\u4E66\u3001\u4F01\u4E1A\u5FAE\u4FE1\u3001QQ Bot",
|
||||
configSchema: {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
properties: {}
|
||||
},
|
||||
/**
|
||||
* 注册所有启用的渠道
|
||||
*
|
||||
* 从 api.config.channels.<id>.enabled 读取配置
|
||||
*/
|
||||
register(api) {
|
||||
registerChinaSetupCli(api, { channels: SUPPORTED_CHANNELS });
|
||||
showChinaInstallHint(api);
|
||||
registerChannelsByConfig(api);
|
||||
}
|
||||
};
|
||||
var index_default = channelsPlugin;
|
||||
|
||||
export { SUPPORTED_CHANNELS, index_default as default, registerChannelsByConfig };
|
||||
//# sourceMappingURL=index.js.map
|
||||
//# sourceMappingURL=index.js.map
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user