From cd3ffcd272d5554e1c37ef0740d04f2c173cf47b Mon Sep 17 00:00:00 2001 From: dank074 Date: Sat, 8 Jan 2022 20:41:15 -0600 Subject: [PATCH 1/2] added bot speech setup --- .../avatar-info/AvatarInfoWidgetView.tsx | 2 +- .../avatar-info/common/BotSkillsEnum.ts | 8 +-- .../AvatarInfoRentableBotChatView.tsx | 51 +++++++++++++++++-- .../AvatarInfoRentableBotChatView.types.ts | 1 + 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx index 41b20557..5ac5f7a0 100644 --- a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx +++ b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx @@ -361,7 +361,7 @@ export const AvatarInfoWidgetView: FC<{}> = props => { return removeProductBubble(index) } />; }) } - { rentableBotChatEvent && } + { rentableBotChatEvent && setRentableBotChatEvent(null)}/> } { confirmingProduct && setConfirmingProduct(null) } /> } ) diff --git a/src/views/room/widgets/avatar-info/common/BotSkillsEnum.ts b/src/views/room/widgets/avatar-info/common/BotSkillsEnum.ts index 3c7043ce..cc7942be 100644 --- a/src/views/room/widgets/avatar-info/common/BotSkillsEnum.ts +++ b/src/views/room/widgets/avatar-info/common/BotSkillsEnum.ts @@ -1,14 +1,14 @@ export class BotSkillsEnum { - public static _Str_19584: number = 0; + public static GENERIC_SKILL: number = 0; public static DRESS_UP: number = 1; public static SETUP_CHAT: number = 2; public static RANDOM_WALK: number = 3; public static DANCE: number = 4; public static CHANGE_BOT_NAME: number = 5; - public static _Str_20280: number = 6; - public static _Str_18934: number = 7; - public static _Str_14917: number = 8; + public static SERVE_BEVERAGE: number = 6; + public static INCLIENT_LINK: number = 7; + public static NUX_PROCEED: number = 8; public static CHANGE_BOT_MOTTO: number = 9; public static NUX_TAKE_TOUR: number = 10; public static NO_PICK_UP: number = 12; diff --git a/src/views/room/widgets/avatar-info/views/rentable-bot-chat/AvatarInfoRentableBotChatView.tsx b/src/views/room/widgets/avatar-info/views/rentable-bot-chat/AvatarInfoRentableBotChatView.tsx index 983e34a2..e4d54eaa 100644 --- a/src/views/room/widgets/avatar-info/views/rentable-bot-chat/AvatarInfoRentableBotChatView.tsx +++ b/src/views/room/widgets/avatar-info/views/rentable-bot-chat/AvatarInfoRentableBotChatView.tsx @@ -1,21 +1,64 @@ -import { FC, useMemo } from 'react'; -import { GetRoomObjectBounds, GetRoomSession } from '../../../../../../api'; +import { BotSkillSaveComposer } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useMemo, useState } from 'react'; +import { GetRoomObjectBounds, GetRoomSession, LocalizeText } from '../../../../../../api'; +import { SendMessageHook } from '../../../../../../hooks'; import { DraggableWindow, DraggableWindowPosition } from '../../../../../../layout'; +import { BotSkillsEnum } from '../../common/BotSkillsEnum'; import { AvatarInfoRentableBotChatViewProps } from './AvatarInfoRentableBotChatView.types'; export const AvatarInfoRentableBotChatView: FC = props => { - const { chatEvent = null } = props; + const { chatEvent = null, close = null } = props; + // eslint-disable-next-line no-template-curly-in-string + 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(() => { return GetRoomObjectBounds(GetRoomSession().roomId, chatEvent.objectId, chatEvent.category, 1); }, [ chatEvent ]); + const formatChatString = useCallback((value: string) => + { + return value.replace(/;#;/g, ' ').replace(/\r\n|\r|\n/g, '\r'); + }, []); + + const save = useCallback(() => + { + const chatConfiguration = formatChatString(newText) + ';#;' + automaticChat + ';#;' + chatDelay + ';#;' + mixSentences; + SendMessageHook(new BotSkillSaveComposer(chatEvent.botId, BotSkillsEnum.SETUP_CHAT, chatConfiguration)); + close(); + }, [automaticChat, chatDelay, chatEvent.botId, close, formatChatString, mixSentences, newText]); + return (
-
test!!!!!
+
+
+
+

{ LocalizeText('bot.skill.chatter.configuration.chat.text') }

+