Skip to content

Commit ea98833

Browse files
authored
Add rainbowme command (#1109)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Adds /rainbowme. Self explanatory #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
2 parents d0ef5e9 + e5e6276 commit ea98833

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

.changeset/rainbowme-command.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sable: patch
3+
---
4+
5+
Add a `/rainbowme` command for sending rainbow-formatted action messages.

src/app/features/room/RoomInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
890890
toMatrixCustomHTML(serializedChildren, {
891891
stripNickname: true,
892892
nickNameReplacement: nicknameReplacement,
893-
forEmote: commandName === Command.Me,
893+
forEmote: commandName === Command.Me || commandName === Command.RainbowMe,
894894
room,
895895
})
896896
);
@@ -971,7 +971,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
971971
toMatrixCustomHTML(serializedChildren, {
972972
stripNickname: true,
973973
nickNameReplacement: nicknameReplacement,
974-
forEmote: commandName === Command.Me,
974+
forEmote: commandName === Command.Me || commandName === Command.RainbowMe,
975975
room,
976976
})
977977
);

src/app/hooks/useCommands.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export enum Command {
265265
Pronoun = 'pronoun',
266266
SPronoun = 'spronoun',
267267
Rainbow = 'rainbow',
268+
RainbowMe = 'rainbowme',
268269
RawMsg = 'rawmsg',
269270
Raw = 'raw',
270271
RawAcc = 'rawacc',
@@ -1162,6 +1163,21 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
11621163
});
11631164
},
11641165
},
1166+
[Command.RainbowMe]: {
1167+
name: Command.RainbowMe,
1168+
description: 'Send a rainbow action message.',
1169+
exe: async (payload, html) => {
1170+
if (!payload || payload.trim().length === 0) return;
1171+
const inputHtml = html || payload;
1172+
const rainbowHtml = rainbowify(inputHtml);
1173+
await mx.sendMessage(room.roomId, {
1174+
msgtype: MsgType.Emote,
1175+
body: payload,
1176+
format: 'org.matrix.custom.html',
1177+
formatted_body: rainbowHtml,
1178+
});
1179+
},
1180+
},
11651181
[Command.RawMsg]: {
11661182
name: Command.RawMsg,
11671183
description:

0 commit comments

Comments
 (0)