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

@@ -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',