Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rainbowme-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sable: patch
---

Add a `/rainbowme` command for sending rainbow-formatted action messages.
4 changes: 2 additions & 2 deletions src/app/features/room/RoomInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
toMatrixCustomHTML(serializedChildren, {
stripNickname: true,
nickNameReplacement: nicknameReplacement,
forEmote: commandName === Command.Me,
forEmote: commandName === Command.Me || commandName === Command.RainbowMe,
room,
})
);
Expand Down Expand Up @@ -971,7 +971,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
toMatrixCustomHTML(serializedChildren, {
stripNickname: true,
nickNameReplacement: nicknameReplacement,
forEmote: commandName === Command.Me,
forEmote: commandName === Command.Me || commandName === Command.RainbowMe,
room,
})
);
Expand Down
16 changes: 16 additions & 0 deletions src/app/hooks/useCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export enum Command {
Pronoun = 'pronoun',
SPronoun = 'spronoun',
Rainbow = 'rainbow',
RainbowMe = 'rainbowme',
RawMsg = 'rawmsg',
Raw = 'raw',
RawAcc = 'rawacc',
Expand Down Expand Up @@ -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:
Expand Down
Loading