Merge pull request #67 from billsonnn/feature/bot-speech

added bot speech setup
This commit is contained in:
Bill 2022-02-16 04:40:21 -05:00 committed by GitHub
commit 8334ceca64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 25 deletions

View File

@ -1,4 +1,4 @@
import { ConfigurationEvent, LegacyExternalInterface, Nitro, NitroCommunicationDemoEvent, NitroEvent, NitroLocalizationEvent, NitroVersion, RoomEngineEvent, WebGL } from '@nitrots/nitro-renderer';
import { ConfigurationEvent, HabboWebTools, LegacyExternalInterface, Nitro, NitroCommunicationDemoEvent, NitroEvent, NitroLocalizationEvent, NitroVersion, RoomEngineEvent, WebGL } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { GetCommunication, GetConfiguration, GetNitroInstance } from './api';
import { useConfigurationEvent } from './hooks/events/core/configuration/configuration-event';
@ -68,6 +68,8 @@ export const App: FC<{}> = props =>
setMessage('Finishing Up');
GetNitroInstance().init();
if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'authentication', 'authok', []);
return;
case NitroCommunicationDemoEvent.CONNECTION_ERROR:
setIsError(true);
@ -79,7 +81,7 @@ export const App: FC<{}> = props =>
setIsError(true);
setMessage('Connection Error');
LegacyExternalInterface.call('disconnect', -1, 'client.init.handshake.fail');
HabboWebTools.send(-1, 'client.init.handshake.fail');
return;
case RoomEngineEvent.ENGINE_INITIALIZED:
setIsReady(true);

View File

@ -1,4 +1,4 @@
import { GenericErrorEvent, GetGuestRoomResultEvent, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomSettingsUpdatedEvent, UserInfoEvent } from '@nitrots/nitro-renderer';
import { GenericErrorEvent, GetGuestRoomResultEvent, LegacyExternalInterface, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomSettingsUpdatedEvent, UserInfoEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback } from 'react';
import { CreateRoomSession, GetSessionDataManager } from '../../api';
import { UpdateDoorStateEvent } from '../../events';
@ -41,6 +41,8 @@ export const NavigatorMessageHandler: FC<NavigatorMessageHandlerProps> = props =
});
SendMessageHook(new RoomInfoComposer(parser.roomId, true, false));
if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'navigator', 'private', [ parser.roomId ]);
}, [ navigatorState, dispatchNavigatorState ]);
const onGetGuestRoomResultEvent = useCallback((event: GetGuestRoomResultEvent) =>

View File

@ -1,10 +1,10 @@
import { MouseEventType } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { AddEventLinkTracker, CreateLinkEvent, GetConfiguration, RemoveLinkEventTracker } from '../../api';
import { AddEventLinkTracker, GetConfiguration, RemoveLinkEventTracker } from '../../api';
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../layout';
import { NotificationUtilities } from '../notification-center/common/NotificationUtilities';
const newLineRegex = /\n\r|\n|\r/mg;
const internalLinkPrefix = 'event:';
export const NitropediaView: FC<{}> = props =>
{
const [ content, setContent ] = useState<string>(null);
@ -40,17 +40,7 @@ export const NitropediaView: FC<{}> = props =>
{
event.preventDefault();
const link = event.target.href;
if(link.startsWith(internalLinkPrefix))
{
const internalLink = link.substring(internalLinkPrefix.length);
CreateLinkEvent(internalLink);
}
else
{
window.open(link);
}
NotificationUtilities.openUrl(link);
}
},[]);

View File

@ -361,7 +361,7 @@ export const AvatarInfoWidgetView: FC<{}> = props =>
{
return <AvatarInfoUseProductView key={ item.id } item={ item } updateConfirmingProduct={ updateConfirmingProduct } close={ () => removeProductBubble(index) } />;
}) }
{ rentableBotChatEvent && <AvatarInfoRentableBotChatView chatEvent={ rentableBotChatEvent } /> }
{ rentableBotChatEvent && <AvatarInfoRentableBotChatView chatEvent={ rentableBotChatEvent } close={ () => setRentableBotChatEvent(null)}/> }
{ confirmingProduct && <AvatarInfoUseProductConfirmView item={ confirmingProduct } close={ () => setConfirmingProduct(null) } /> }
</>
)

View File

@ -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;

View File

@ -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<AvatarInfoRentableBotChatViewProps> = props =>
{
const { chatEvent = null } = props;
const { chatEvent = null, close = null } = props;
// eslint-disable-next-line no-template-curly-in-string
const [ newText, setNewText ] = useState<string>(chatEvent.chat === '${bot.skill.chatter.configuration.text.placeholder}' ? '' : chatEvent.chat);
const [ automaticChat, setAutomaticChat ] = useState<boolean>(chatEvent.automaticChat);
const [ mixSentences, setMixSentences ] = useState<boolean>(chatEvent.mixSentences);
const [ chatDelay, setChatDelay ] = useState<number>(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 (
<DraggableWindow position={ DraggableWindowPosition.NOTHING } handleSelector=".drag-handler" style={ { top: getObjectLocation.y, left: getObjectLocation.x } }>
<div className="nitro-context-menu">
<div className="drag-handler">test!!!!!</div>
<div className="drag-handler">
<div className="px-2">
<div className="d-flex flex-column menu-item">
<p className="mb-1">{ LocalizeText('bot.skill.chatter.configuration.chat.text') }</p>
<textarea className="form-control form-control-sm mb-2" placeholder={LocalizeText('bot.skill.chatter.configuration.text.placeholder')} value={newText} rows={7} onChange={e => setNewText(e.target.value)}/>
</div>
<div className="d-flex flex-row menu-item">
<p className="mb-1 me-2">{ LocalizeText('bot.skill.chatter.configuration.automatic.chat') }</p>
<input type="checkbox" className="form-check-input" checked={automaticChat} onChange={e => setAutomaticChat(e.target.checked)} />
</div>
<div className="d-flex flex-row menu-item">
<p className="mb-1 me-2">{ LocalizeText('bot.skill.chatter.configuration.markov')}</p>
<input type="checkbox" className="form-check-input" checked={mixSentences} onChange={ e => setMixSentences(e.target.checked)} />
</div>
<div className="d-flex flex-row menu-item">
<p className="mb-1 me-2">{ LocalizeText('bot.skill.chatter.configuration.chat.delay') }</p>
<input type="number" className="form-control form-control-sm mb-2" value={chatDelay} onChange={e => setChatDelay(e.target.valueAsNumber)}/>
</div>
<div className="d-flex flex-row justify-content-between mt-1">
<button type="button" className="btn btn-secondary btn-sm" onClick={close}>{ LocalizeText('cancel')}</button>
<button type="button" className="btn btn-success btn-sm" onClick={save}>{ LocalizeText('save') }</button>
</div>
</div>
</div>
</div>
</DraggableWindow>
);

View File

@ -3,4 +3,5 @@ import { RoomWidgetUpdateRentableBotChatEvent } from '../../../../../../api';
export interface AvatarInfoRentableBotChatViewProps
{
chatEvent: RoomWidgetUpdateRentableBotChatEvent;
close(): void;
}