feat(channels): restore WhatsApp config compatibility

This commit is contained in:
晴天
2026-05-23 07:51:16 +08:00
parent 8d745e7543
commit d933177ec3
6 changed files with 473 additions and 16 deletions

View File

@@ -364,6 +364,24 @@ export default {
gatewayNotConnected: _('Gateway 未连接', 'Gateway not connected', 'Gateway 未連線'),
generatingQr: _('正在生成二维码...', 'Generating QR code...', '正在生成二维碼...'),
generatingQrShort: _('生成二维码...', 'Generating QR...', '生成二维碼...'),
whatsappDesc: _('通过 WhatsApp 个人号扫码登录接入,支持私聊、群组和本地会话运行参数', 'Connect a WhatsApp personal account via QR login, with DM, group, and local session runtime options', '透過 WhatsApp 個人號掃碼登入接入,支援私聊、群組和本地會話執行參數'),
whatsappGuide1: _('先安装 <strong>@openclaw/whatsapp</strong> 插件,保存配置时面板会自动尝试启用插件', 'Install the <strong>@openclaw/whatsapp</strong> plugin first; the panel will try to enable it on save', '先安裝 <strong>@openclaw/whatsapp</strong> 外掛,儲存設定時面板會自動嘗試啟用外掛'),
whatsappGuide2: _('保存配置后点击「启动扫码登录」,用手机 WhatsApp 扫描二维码完成设备链接', 'After saving config, click "Start QR Login" and scan the QR code with WhatsApp to link the device', '儲存設定後點擊「啟動掃碼登入」,用手機 WhatsApp 掃描 QR code 完成裝置連結'),
whatsappGuide3: _('Allow From / Group Allow From 推荐填写手机号或群组 JID留空则按策略默认处理', 'Use phone numbers or group JIDs for Allow From / Group Allow From; leave empty to use policy defaults', 'Allow From / Group Allow From 建議填寫手機號或群組 JID留空則按策略預設處理'),
whatsappGuide4: _('如扫码入口提示插件未加载,请保存配置、重启 Gateway并确认插件已在 OpenClaw 中加载', 'If QR login says the plugin is not loaded, save config, restart Gateway, and confirm the plugin is loaded by OpenClaw', '如掃碼入口提示外掛未載入,請儲存設定、重啟 Gateway並確認外掛已在 OpenClaw 中載入'),
whatsappGuideFooter: _('<div style="margin-top:8px;font-size:var(--font-size-xs);color:var(--text-tertiary)">WhatsApp 使用本地扫码会话,不需要 Bot Token建议使用独立号码并注意账号风控风险。</div>', '<div style="margin-top:8px;font-size:var(--font-size-xs);color:var(--text-tertiary)">WhatsApp uses a local QR-linked session and does not need a Bot Token; a separate number is recommended because account risk may apply.</div>', '<div style="margin-top:8px;font-size:var(--font-size-xs);color:var(--text-tertiary)">WhatsApp 使用本地掃碼會話,不需要 Bot Token建議使用獨立號碼並注意帳號風控風險。</div>'),
whatsappLogin: _('启动扫码登录', 'Start QR Login', '啟動掃碼登入'),
whatsappLoginHint: _('通过 Gateway WebSocket 启动 WhatsApp 二维码登录流程', 'Start the WhatsApp QR login flow through Gateway WebSocket', '透過 Gateway WebSocket 啟動 WhatsApp QR code 登入流程'),
whatsappSelfChatMode: _('自聊模式', 'Self Chat Mode', '自聊模式'),
whatsappSelfChatHint: _('开启后可将自己的 WhatsApp 会话用于本地测试或个人助手场景。', 'Enable this to use your own WhatsApp chat for local testing or personal assistant scenarios.', '開啟後可將自己的 WhatsApp 會話用於本地測試或個人助理場景。'),
whatsappAllowFromPh: _('可选,逗号分隔手机号或联系人 JID', 'Optional, comma-separated phone numbers or contact JIDs', '可選,逗號分隔手機號或聯絡人 JID'),
whatsappGroupAllowFromPh: _('可选,逗号分隔群组 JID例如 120363...@g.us', 'Optional, comma-separated group JIDs, e.g. 120363...@g.us', '可選,逗號分隔群組 JID例如 120363...@g.us'),
whatsappDebounceHint: _('合并短时间内连续消息的等待时间,单位毫秒。', 'Delay used to coalesce rapid messages, in milliseconds.', '合併短時間內連續訊息的等待時間,單位毫秒。'),
whatsappReadReceipts: _('发送已读回执', 'Send read receipts', '傳送已讀回執'),
whatsappConfigWrites: _('允许配置写入', 'Allow config writes', '允許設定寫入'),
whatsappAckEmoji: _('确认反应表情', 'Ack reaction emoji', '確認反應表情'),
whatsappAckDirect: _('私聊确认反应', 'Ack direct chats', '私聊確認反應'),
whatsappAckGroup: _('群组确认反应', 'Ack group chats', '群組確認反應'),
whatsappScanQr: _('用手机 WhatsApp 扫描此二维码', 'Scan this QR code with WhatsApp on your phone', '用手機 WhatsApp 掃描此二维碼'),
whatsappScanPath: _('WhatsApp → 已连接的设备 → 连接设备', 'WhatsApp → Linked Devices → Link a Device', 'WhatsApp → 已連線的設備 → 連線設備'),
waitingScan: _('等待扫码...', 'Waiting for scan...', '等待掃碼...'),

View File

@@ -395,8 +395,76 @@ const PLATFORM_REGISTRY = {
configKey: 'slack',
pairingChannel: 'slack',
},
// WhatsApp 已移除上游插件运行时未加载web.login.start 返回 "not available"
// 等上游修复后可重新启用
whatsapp: {
label: 'WhatsApp',
iconName: 'message-circle',
desc: t('channels.whatsappDesc'),
guide: [
t('channels.whatsappGuide1'),
t('channels.whatsappGuide2'),
t('channels.whatsappGuide3'),
t('channels.whatsappGuide4'),
],
guideFooter: t('channels.whatsappGuideFooter'),
actions: [
{ id: 'login', label: t('channels.whatsappLogin'), hint: t('channels.whatsappLoginHint'), useGatewayLogin: true },
],
fields: [
{ key: 'selfChatMode', label: t('channels.whatsappSelfChatMode'), type: 'select', options: BOOLEAN_OPTIONS, required: false, hint: t('channels.whatsappSelfChatHint') },
{ key: 'dmPolicy', label: t('channels.dmPolicy'), type: 'select', options: DM_POLICY_OPTIONS, required: false },
{ key: 'groupPolicy', label: t('channels.groupPolicy'), type: 'select', options: GROUP_POLICY_OPTIONS(t('channels.groupAllGroups')), required: false },
{ key: 'allowFrom', label: 'Allow From', placeholder: t('channels.whatsappAllowFromPh'), required: false, hint: t('channels.allowFromHint') },
{ key: 'defaultTo', label: 'Default To', placeholder: t('channels.optionalEg', { example: '+15550001111' }), required: false },
{ key: 'groupAllowFrom', label: 'Group Allow From', placeholder: t('channels.whatsappGroupAllowFromPh'), required: false, hint: t('channels.groupAllowFromHint') },
{ key: 'historyLimit', label: 'History Limit', placeholder: '80', required: false },
{ key: 'dmHistoryLimit', label: 'DM History Limit', placeholder: '20', required: false },
{ key: 'mediaMaxMb', label: 'Media Max MB', placeholder: '50', required: false },
{ key: 'debounceMs', label: 'Debounce MS', placeholder: '800', required: false, hint: t('channels.whatsappDebounceHint') },
{ key: 'textChunkLimit', label: 'Text Chunk Limit', placeholder: '1800', required: false },
{ key: 'contextVisibility', label: 'Context Visibility', type: 'select', options: [
{ value: '', label: t('channels.policyDefault') },
{ value: 'all', label: 'All' },
{ value: 'allowlist', label: 'Allowlist' },
{ value: 'allowlist_quote', label: 'Allowlist + Quote' },
], required: false },
{ key: 'chunkMode', label: 'Chunk Mode', type: 'select', options: [
{ value: '', label: t('channels.policyDefault') },
{ value: 'length', label: 'Length' },
{ value: 'newline', label: 'Newline' },
], required: false },
{ key: 'blockStreaming', label: t('channels.signalBlockStreaming'), type: 'select', options: BOOLEAN_OPTIONS, required: false },
{ key: 'sendReadReceipts', label: t('channels.whatsappReadReceipts'), type: 'select', options: BOOLEAN_OPTIONS, required: false },
{ key: 'configWrites', label: t('channels.whatsappConfigWrites'), type: 'select', options: BOOLEAN_OPTIONS, required: false },
{ key: 'reactionLevel', label: 'Reaction Level', type: 'select', options: [
{ value: '', label: t('channels.policyDefault') },
{ value: 'off', label: t('channels.disable') },
{ value: 'ack', label: 'Ack' },
{ value: 'minimal', label: 'Minimal' },
{ value: 'extensive', label: 'Extensive' },
], required: false },
{ key: 'replyToMode', label: 'Reply To Mode', type: 'select', options: [
{ value: '', label: t('channels.policyDefault') },
{ value: 'off', label: t('channels.disable') },
{ value: 'first', label: 'First' },
{ value: 'all', label: 'All' },
{ value: 'batched', label: 'Batched' },
], required: false },
{ key: 'ackEmoji', label: t('channels.whatsappAckEmoji'), placeholder: t('channels.optionalEg', { example: '✅' }), required: false },
{ key: 'ackDirect', label: t('channels.whatsappAckDirect'), type: 'select', options: BOOLEAN_OPTIONS, required: false },
{ key: 'ackGroup', label: t('channels.whatsappAckGroup'), type: 'select', options: [
{ value: '', label: t('channels.policyDefault') },
{ value: 'always', label: 'Always' },
{ value: 'mentions', label: 'Mentions' },
{ value: 'never', label: 'Never' },
], required: false },
{ key: 'messagePrefix', label: 'Message Prefix', placeholder: t('channels.optionalEg', { example: '[WA]' }), required: false },
{ key: 'responsePrefix', label: 'Response Prefix', placeholder: t('channels.optionalEg', { example: '[AI]' }), required: false },
],
configKey: 'whatsapp',
pairingChannel: 'whatsapp',
pluginRequired: '@openclaw/whatsapp@latest',
pluginId: 'whatsapp',
},
weixin: {
label: t('channels.weixinLabel'),
iconName: 'message-circle',