add headpat cute event command and integrate into message rendering
This commit is contained in:
4 files changed
+32
-3
No files matched your search
@@ -2,4 +2,4 @@
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Add `/hug`, `/cuddle`, `/wave`, and `/poke` slash commands.
|
||||
Add `/hug`, `/cuddle`, `/wave`, `/headpat`, and `/poke` slash commands.
|
||||
@@ -33,7 +33,7 @@ import { ImageViewer } from './image-viewer';
|
||||
import { PdfViewer } from './Pdf-viewer';
|
||||
import { TextViewer } from './text-viewer';
|
||||
import { ClientSideHoverFreeze } from './ClientSideHoverFreeze';
|
||||
import { MCuteEvent } from './message/MCuteEvent';
|
||||
import { CuteEventType, MCuteEvent } from './message/MCuteEvent';
|
||||
|
||||
type RenderMessageContentProps = {
|
||||
displayName: string;
|
||||
@@ -358,6 +358,14 @@ function RenderMessageContentInternal({
|
||||
mentionedUserIds={content?.['m.mentions']?.user_ids}
|
||||
/>
|
||||
);
|
||||
if (msgType === 'fyi.cisnt.headpat')
|
||||
return (
|
||||
<MCuteEvent
|
||||
content={content}
|
||||
type={CuteEventType.Headpat}
|
||||
mentionedUserIds={content?.['m.mentions']?.user_ids}
|
||||
/>
|
||||
);
|
||||
return <UnsupportedContent />;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
import { MessageTextBody } from './layout';
|
||||
|
||||
enum CuteEventType {
|
||||
export enum CuteEventType {
|
||||
Hug = 'hug',
|
||||
Cuddle = 'cuddle',
|
||||
Wave = 'wave',
|
||||
Poke = 'poke',
|
||||
Headpat = 'headpat',
|
||||
// currently unused, but could be added in the future if there's demand for it
|
||||
Kiss = 'kiss',
|
||||
}
|
||||
@@ -44,6 +45,9 @@ export function MCuteEvent({ content, type, mentionedUserIds }: MCuteEventProps)
|
||||
case CuteEventType.Poke:
|
||||
cuteText = `pokes ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
case CuteEventType.Headpat:
|
||||
cuteText = `gives headpats to ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
default:
|
||||
cuteText = `sends ${mentionedUserIds?.[0] || 'you'} a cute event`;
|
||||
}
|
||||
|
||||
@@ -247,6 +247,7 @@ export enum Command {
|
||||
// our own cute events, not part of FluffyChat or other clients
|
||||
Wave = 'wave',
|
||||
Poke = 'poke',
|
||||
Headpat = 'headpat',
|
||||
}
|
||||
|
||||
export type CommandContent = {
|
||||
@@ -1362,6 +1363,22 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
[Command.Headpat]: {
|
||||
name: Command.Headpat,
|
||||
description: 'Send a headpat to someone. Example: /headpat [@user:example.org]',
|
||||
// not really like any of the other cute events, but it was too good not to include
|
||||
// using a custom msgtype to avoid confusion with the other existing cute events
|
||||
exe: async (payload) => {
|
||||
const target = payload.trim();
|
||||
await mx.sendMessage(room.roomId, {
|
||||
msgtype: 'fyi.cisnt.headpat',
|
||||
'm.mentions': {
|
||||
user_ids: target ? [target] : [],
|
||||
},
|
||||
body: `*pat pat*`,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
}),
|
||||
[mx, navigateRoom, room, profile.displayName, profile.avatarUrl, developerTools]
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user