feat(feishu): Add group chat trigger and random emoji response frontend configuration (#2607)
- 添加 group_trigger.mention_only 开关配置(群聊仅提及时响应) - 添加 random_reaction_emoji 数组配置(自定义表情回应列表) - 更新中英文国际化翻译
This commit is contained in:
parent
6ca7311273
commit
a5379d5fff
3 changed files with 48 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import {
|
||||||
import {
|
import {
|
||||||
asStringArray,
|
asStringArray,
|
||||||
parseAllowFromInput,
|
parseAllowFromInput,
|
||||||
|
parseConservativeStringListInput,
|
||||||
} from "@/components/channels/channel-array-utils"
|
} from "@/components/channels/channel-array-utils"
|
||||||
import { getSecretInputPlaceholder } from "@/components/channels/channel-config-fields"
|
import { getSecretInputPlaceholder } from "@/components/channels/channel-config-fields"
|
||||||
import { Field, KeyInput, SwitchCardField } from "@/components/shared-form"
|
import { Field, KeyInput, SwitchCardField } from "@/components/shared-form"
|
||||||
|
|
@ -34,6 +35,13 @@ function asBool(value: unknown): boolean {
|
||||||
return typeof value === "boolean" ? value : false
|
return typeof value === "boolean" ? value : false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function asRecord(value: unknown): Record<string, unknown> {
|
||||||
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
||||||
|
return value as Record<string, unknown>
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
export function FeishuForm({
|
export function FeishuForm({
|
||||||
config,
|
config,
|
||||||
onChange,
|
onChange,
|
||||||
|
|
@ -43,6 +51,7 @@ export function FeishuForm({
|
||||||
arrayFieldResetVersion,
|
arrayFieldResetVersion,
|
||||||
}: FeishuFormProps) {
|
}: FeishuFormProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const groupTriggerConfig = asRecord(config.group_trigger)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
|
|
@ -137,6 +146,37 @@ export function FeishuForm({
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<Card className="py-3 shadow-sm">
|
||||||
|
<CardContent className="divide-border/60 divide-y px-6 py-0 [&>div]:py-5">
|
||||||
|
<div>
|
||||||
|
<SwitchCardField
|
||||||
|
label={t("channels.field.groupTriggerMentionOnly")}
|
||||||
|
hint={t("channels.form.desc.groupTriggerMentionOnly")}
|
||||||
|
checked={asBool(groupTriggerConfig.mention_only)}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
onChange("group_trigger", {
|
||||||
|
...groupTriggerConfig,
|
||||||
|
mention_only: checked,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
ariaLabel={t("channels.field.groupTriggerMentionOnly")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ChannelArrayListField
|
||||||
|
label={t("channels.field.randomReactionEmoji")}
|
||||||
|
hint={t("channels.form.desc.randomReactionEmoji")}
|
||||||
|
value={asStringArray(config.random_reaction_emoji)}
|
||||||
|
onChange={(value) => onChange("random_reaction_emoji", value)}
|
||||||
|
placeholder={t("channels.field.randomReactionEmojiPlaceholder")}
|
||||||
|
parser={parseConservativeStringListInput}
|
||||||
|
fieldPath="random_reaction_emoji"
|
||||||
|
registerFlusher={registerArrayFieldFlusher}
|
||||||
|
resetVersion={arrayFieldResetVersion}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,9 @@
|
||||||
"placeholderText": "Placeholder Text",
|
"placeholderText": "Placeholder Text",
|
||||||
"groupTriggerMentionOnly": "Group Mention Only",
|
"groupTriggerMentionOnly": "Group Mention Only",
|
||||||
"groupTriggerPrefixes": "Group Trigger Prefixes",
|
"groupTriggerPrefixes": "Group Trigger Prefixes",
|
||||||
|
"groupTriggerPrefixesPlaceholder": "e.g. /, !, ?",
|
||||||
|
"randomReactionEmoji": "Random Reaction Emoji",
|
||||||
|
"randomReactionEmojiPlaceholder": "e.g. THUMBSUP, HEART, SMILE",
|
||||||
"isLark": "Lark (International)",
|
"isLark": "Lark (International)",
|
||||||
"allowFrom": "Allow From",
|
"allowFrom": "Allow From",
|
||||||
"allowFromPlaceholder": "e.g. 123456, 789012",
|
"allowFromPlaceholder": "e.g. 123456, 789012",
|
||||||
|
|
@ -393,6 +396,7 @@
|
||||||
"placeholderEnabled": "Enable temporary placeholder messages before the final reply is sent.",
|
"placeholderEnabled": "Enable temporary placeholder messages before the final reply is sent.",
|
||||||
"groupTriggerMentionOnly": "In group chats, respond only when the bot is mentioned.",
|
"groupTriggerMentionOnly": "In group chats, respond only when the bot is mentioned.",
|
||||||
"groupTriggerPrefixes": "Custom group-chat trigger prefixes. Add items one by one, or paste multiple values at once.",
|
"groupTriggerPrefixes": "Custom group-chat trigger prefixes. Add items one by one, or paste multiple values at once.",
|
||||||
|
"randomReactionEmoji": "PicoClaw adds emoji reactions to user messages to confirm receipt. Example: \"THUMBSUP\", \"HEART\", \"SMILE\". Leave empty to use the default \"Pin\" emoji.",
|
||||||
"isLark": "Use Lark international domain (open.larksuite.com) instead of Feishu domain (open.feishu.cn).",
|
"isLark": "Use Lark international domain (open.larksuite.com) instead of Feishu domain (open.feishu.cn).",
|
||||||
"allowFrom": "Allowed user or group IDs. Add items one by one, or paste multiple values at once.",
|
"allowFrom": "Allowed user or group IDs. Add items one by one, or paste multiple values at once.",
|
||||||
"allowOrigins": "Allowed origin domains. Add items one by one, or paste multiple values at once.",
|
"allowOrigins": "Allowed origin domains. Add items one by one, or paste multiple values at once.",
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,9 @@
|
||||||
"placeholderText": "占位文案",
|
"placeholderText": "占位文案",
|
||||||
"groupTriggerMentionOnly": "群聊仅提及时响应",
|
"groupTriggerMentionOnly": "群聊仅提及时响应",
|
||||||
"groupTriggerPrefixes": "群聊触发前缀",
|
"groupTriggerPrefixes": "群聊触发前缀",
|
||||||
|
"groupTriggerPrefixesPlaceholder": "例如 /, !, ?",
|
||||||
|
"randomReactionEmoji": "随机表情回应",
|
||||||
|
"randomReactionEmojiPlaceholder": "例如 THUMBSUP, HEART, SMILE",
|
||||||
"isLark": "Lark(国际版)",
|
"isLark": "Lark(国际版)",
|
||||||
"allowFrom": "允许来源",
|
"allowFrom": "允许来源",
|
||||||
"allowFromPlaceholder": "例如 123456, 789012",
|
"allowFromPlaceholder": "例如 123456, 789012",
|
||||||
|
|
@ -393,6 +396,7 @@
|
||||||
"placeholderEnabled": "在最终回复发送前,先发送临时占位消息",
|
"placeholderEnabled": "在最终回复发送前,先发送临时占位消息",
|
||||||
"groupTriggerMentionOnly": "在群聊中仅当提及机器人时才响应",
|
"groupTriggerMentionOnly": "在群聊中仅当提及机器人时才响应",
|
||||||
"groupTriggerPrefixes": "群聊触发前缀。可逐项添加,也支持一次粘贴多个值。",
|
"groupTriggerPrefixes": "群聊触发前缀。可逐项添加,也支持一次粘贴多个值。",
|
||||||
|
"randomReactionEmoji": "PicoClaw 会对用户消息添加表情回复以确认已收到。例如:\"THUMBSUP\", \"HEART\", \"SMILE\"。留空则使用默认的 \"Pin\" 表情。",
|
||||||
"isLark": "使用 Lark 国际版域名(open.larksuite.com)替代飞书域名(open.feishu.cn)",
|
"isLark": "使用 Lark 国际版域名(open.larksuite.com)替代飞书域名(open.feishu.cn)",
|
||||||
"allowFrom": "允许访问的用户或群组 ID。可逐项添加,也支持一次粘贴多个值。",
|
"allowFrom": "允许访问的用户或群组 ID。可逐项添加,也支持一次粘贴多个值。",
|
||||||
"allowOrigins": "允许访问的来源域名。可逐项添加,也支持一次粘贴多个值。",
|
"allowOrigins": "允许访问的来源域名。可逐项添加,也支持一次粘贴多个值。",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue