diff --git a/.changeset/rainbowme-command.md b/.changeset/rainbowme-command.md new file mode 100644 index 0000000000..263d03aa71 --- /dev/null +++ b/.changeset/rainbowme-command.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Add a `/rainbowme` command for sending rainbow-formatted action messages. diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 6fe77af887..6a170c996d 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -890,7 +890,7 @@ export const RoomInput = forwardRef( toMatrixCustomHTML(serializedChildren, { stripNickname: true, nickNameReplacement: nicknameReplacement, - forEmote: commandName === Command.Me, + forEmote: commandName === Command.Me || commandName === Command.RainbowMe, room, }) ); @@ -971,7 +971,7 @@ export const RoomInput = forwardRef( toMatrixCustomHTML(serializedChildren, { stripNickname: true, nickNameReplacement: nicknameReplacement, - forEmote: commandName === Command.Me, + forEmote: commandName === Command.Me || commandName === Command.RainbowMe, room, }) ); diff --git a/src/app/hooks/useCommands.ts b/src/app/hooks/useCommands.ts index 9c9451be8a..6bdfdf7a4c 100644 --- a/src/app/hooks/useCommands.ts +++ b/src/app/hooks/useCommands.ts @@ -265,6 +265,7 @@ export enum Command { Pronoun = 'pronoun', SPronoun = 'spronoun', Rainbow = 'rainbow', + RainbowMe = 'rainbowme', RawMsg = 'rawmsg', Raw = 'raw', RawAcc = 'rawacc', @@ -1162,6 +1163,21 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { }); }, }, + [Command.RainbowMe]: { + name: Command.RainbowMe, + description: 'Send a rainbow action message.', + exe: async (payload, html) => { + if (!payload || payload.trim().length === 0) return; + const inputHtml = html || payload; + const rainbowHtml = rainbowify(inputHtml); + await mx.sendMessage(room.roomId, { + msgtype: MsgType.Emote, + body: payload, + format: 'org.matrix.custom.html', + formatted_body: rainbowHtml, + }); + }, + }, [Command.RawMsg]: { name: Command.RawMsg, description: