From ebb8b993ef43e3a4ef1a5ee075f5f290cd22e53d Mon Sep 17 00:00:00 2001 From: Layne Date: Wed, 16 Mar 2022 15:19:32 -0400 Subject: [PATCH 1/3] optional sounds notif/resp --- public/ui-config.json.example | 4 ++++ .../nitro/room/widgets/handlers/RoomWidgetChatHandler.ts | 6 ++++-- src/api/notification/NotificationUtilities.ts | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/ui-config.json.example b/public/ui-config.json.example index 5463c31e..3410db79 100644 --- a/public/ui-config.json.example +++ b/public/ui-config.json.example @@ -59,6 +59,10 @@ "catalog.buy": "habbo_club", "catalog.gifts": "club_gifts" }, + "respect.options": { + "enabled": false, + "sound": "sound_respect_received" + }, "currency.display.number.short": false, "currency.asset.icon.url": "${images.url}/wallet/%type%.png", "catalog.asset.url": "${image.library.url}catalogue", diff --git a/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts b/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts index 53ca74f2..f0571e18 100644 --- a/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts +++ b/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts @@ -1,5 +1,5 @@ import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, IAvatarImageListener, INitroPoint, IVector3D, NitroEvent, NitroPoint, PetFigureData, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionChatEvent, RoomWidgetEnum, SystemChatStyleEnum, TextureUtils, Vector3d } from '@nitrots/nitro-renderer'; -import { GetAvatarRenderManager, GetRoomEngine } from '../../../..'; +import { GetAvatarRenderManager, GetConfigurationManager, GetRoomEngine, PlaySound } from '../../../..'; import { LocalizeText } from '../../../../utils/LocalizeText'; import { RoomWidgetUpdateChatEvent, RoomWidgetUpdateEvent } from '../events'; import { RoomWidgetMessage } from '../messages'; @@ -63,7 +63,9 @@ export class RoomWidgetChatHandler extends RoomWidgetHandler implements IAvatarI switch(chatType) { case RoomSessionChatEvent.CHAT_TYPE_RESPECT: - text = LocalizeText('widgets.chatbubble.respect', [ 'username' ], [ username ]); + text = LocalizeText('widgets.chatbubble.respect', ['username'], [username]); + if(GetConfigurationManager().getValue('respect.options')['enabled']) + PlaySound(GetConfigurationManager().getValue('respect.options')['sound']) break; case RoomSessionChatEvent.CHAT_TYPE_PETRESPECT: text = LocalizeText('widget.chatbubble.petrespect', [ 'petname' ], [ username ]); diff --git a/src/api/notification/NotificationUtilities.ts b/src/api/notification/NotificationUtilities.ts index 27979b52..f3311027 100644 --- a/src/api/notification/NotificationUtilities.ts +++ b/src/api/notification/NotificationUtilities.ts @@ -1,5 +1,5 @@ import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer'; -import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '..'; +import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText, PlaySound } from '..'; import { CatalogPageName } from '../../components/catalog/common/CatalogPageName'; import { NotificationAlertEvent, NotificationConfirmEvent } from '../../events'; import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent'; @@ -86,6 +86,8 @@ export class NotificationUtilities { this.simpleAlert(message, NotificationAlertType.EVENT, linkUrl, linkTitle, title, image); } + + if(options.get('sound')) PlaySound(options.get('sound')); } public static showSingleBubble(message: string, type: string, imageUrl: string = null, internalLink: string = null): void From 0b46b18f4bcd393850f0bcfe3bf387ad0a4d731e Mon Sep 17 00:00:00 2001 From: Layne Date: Wed, 16 Mar 2022 19:20:59 +0000 Subject: [PATCH 2/3] Revert "optional sounds notif/resp" This reverts commit ebb8b993ef43e3a4ef1a5ee075f5f290cd22e53d --- public/ui-config.json.example | 4 ---- .../nitro/room/widgets/handlers/RoomWidgetChatHandler.ts | 6 ++---- src/api/notification/NotificationUtilities.ts | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/public/ui-config.json.example b/public/ui-config.json.example index 3410db79..5463c31e 100644 --- a/public/ui-config.json.example +++ b/public/ui-config.json.example @@ -59,10 +59,6 @@ "catalog.buy": "habbo_club", "catalog.gifts": "club_gifts" }, - "respect.options": { - "enabled": false, - "sound": "sound_respect_received" - }, "currency.display.number.short": false, "currency.asset.icon.url": "${images.url}/wallet/%type%.png", "catalog.asset.url": "${image.library.url}catalogue", diff --git a/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts b/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts index f0571e18..53ca74f2 100644 --- a/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts +++ b/src/api/nitro/room/widgets/handlers/RoomWidgetChatHandler.ts @@ -1,5 +1,5 @@ import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, IAvatarImageListener, INitroPoint, IVector3D, NitroEvent, NitroPoint, PetFigureData, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionChatEvent, RoomWidgetEnum, SystemChatStyleEnum, TextureUtils, Vector3d } from '@nitrots/nitro-renderer'; -import { GetAvatarRenderManager, GetConfigurationManager, GetRoomEngine, PlaySound } from '../../../..'; +import { GetAvatarRenderManager, GetRoomEngine } from '../../../..'; import { LocalizeText } from '../../../../utils/LocalizeText'; import { RoomWidgetUpdateChatEvent, RoomWidgetUpdateEvent } from '../events'; import { RoomWidgetMessage } from '../messages'; @@ -63,9 +63,7 @@ export class RoomWidgetChatHandler extends RoomWidgetHandler implements IAvatarI switch(chatType) { case RoomSessionChatEvent.CHAT_TYPE_RESPECT: - text = LocalizeText('widgets.chatbubble.respect', ['username'], [username]); - if(GetConfigurationManager().getValue('respect.options')['enabled']) - PlaySound(GetConfigurationManager().getValue('respect.options')['sound']) + text = LocalizeText('widgets.chatbubble.respect', [ 'username' ], [ username ]); break; case RoomSessionChatEvent.CHAT_TYPE_PETRESPECT: text = LocalizeText('widget.chatbubble.petrespect', [ 'petname' ], [ username ]); diff --git a/src/api/notification/NotificationUtilities.ts b/src/api/notification/NotificationUtilities.ts index f3311027..27979b52 100644 --- a/src/api/notification/NotificationUtilities.ts +++ b/src/api/notification/NotificationUtilities.ts @@ -1,5 +1,5 @@ import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer'; -import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText, PlaySound } from '..'; +import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '..'; import { CatalogPageName } from '../../components/catalog/common/CatalogPageName'; import { NotificationAlertEvent, NotificationConfirmEvent } from '../../events'; import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent'; @@ -86,8 +86,6 @@ export class NotificationUtilities { this.simpleAlert(message, NotificationAlertType.EVENT, linkUrl, linkTitle, title, image); } - - if(options.get('sound')) PlaySound(options.get('sound')); } public static showSingleBubble(message: string, type: string, imageUrl: string = null, internalLink: string = null): void From d5361ef5b39a2f152636d605406bec8d60565a9e Mon Sep 17 00:00:00 2001 From: object Date: Sat, 6 Aug 2022 01:16:30 +0000 Subject: [PATCH 3/3] Fix prevent zalgo-text (Issue #23) --- .../room/widgets/chat-input/ChatInputView.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/room/widgets/chat-input/ChatInputView.tsx b/src/components/room/widgets/chat-input/ChatInputView.tsx index dcfb514e..b474378d 100644 --- a/src/components/room/widgets/chat-input/ChatInputView.tsx +++ b/src/components/room/widgets/chat-input/ChatInputView.tsx @@ -89,6 +89,15 @@ export const ChatInputView: FC<{}> = props => if(text.length <= maxChatLength) { + const re = /%CC%/g + const hasZalgo = txt => re.test(encodeURIComponent(txt)); + + if (hasZalgo(text)) + { + setChatValue(''); + return; + } + setChatValue(''); sendChat(text, chatType, recipientName, chatStyleId); } @@ -141,7 +150,7 @@ export const ChatInputView: FC<{}> = props => } return; } - + }, [ floodBlocked, inputRef, chatModeIdWhisper, anotherInputHasFocus, setInputFocus, checkSpecialKeywordForInput, sendChatValue ]); useUiEvent(RoomWidgetUpdateChatInputContentEvent.CHAT_INPUT_CONTENT, event =>