import { BotSkillSaveComposer } from '@nitrots/nitro-renderer'; import { FC, useMemo, useState } from 'react'; import { BotSkillsEnum, GetRoomObjectBounds, GetRoomSession, LocalizeText, RoomWidgetUpdateRentableBotChatEvent, SendMessageComposer } from '../../../../api'; import { Button, Column, DraggableWindow, DraggableWindowPosition, Flex, Text } from '../../../../common'; import { NitroInput } from '../../../../layout'; import { ContextMenuHeaderView } from '../context-menu/ContextMenuHeaderView'; interface AvatarInfoRentableBotChatViewProps { chatEvent: RoomWidgetUpdateRentableBotChatEvent; onClose(): void; } export const AvatarInfoRentableBotChatView: FC = props => { const { chatEvent = null, onClose = null } = props; const [ newText, setNewText ] = useState(chatEvent.chat === '${bot.skill.chatter.configuration.text.placeholder}' ? '' : chatEvent.chat); const [ automaticChat, setAutomaticChat ] = useState(chatEvent.automaticChat); const [ mixSentences, setMixSentences ] = useState(chatEvent.mixSentences); const [ chatDelay, setChatDelay ] = useState(chatEvent.chatDelay); const getObjectLocation = useMemo(() => GetRoomObjectBounds(GetRoomSession().roomId, chatEvent.objectId, chatEvent.category, 1), [ chatEvent ]); const formatChatString = (value: string) => value.replace(/;#;/g, ' ').replace(/\r\n|\r|\n/g, '\r'); const save = () => { const chatConfiguration = formatChatString(newText) + ';#;' + automaticChat + ';#;' + chatDelay + ';#;' + mixSentences; SendMessageComposer(new BotSkillSaveComposer(chatEvent.botId, BotSkillsEnum.SETUP_CHAT, chatConfiguration)); onClose(); }; return (
{ LocalizeText('bot.skill.chatter.configuration.title') }
{ LocalizeText('bot.skill.chatter.configuration.chat.text') }