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
66 changes: 66 additions & 0 deletions apps/api/src/handlers/call-roomote-via-emoji.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions apps/api/src/handlers/call-roomote-via-emoji.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { reactionEmojiMatches } from '@roomote/communication/reaction-emoji';
import { getAutomationRuntime } from '@roomote/db/server';

export const CALL_ROOMOTE_VIA_EMOJI_PROMPT = 'Act on this';

type CallRoomoteViaEmojiConfiguration = {
emoji: string;
prompt: string;
};

export async function getCallRoomoteViaEmojiConfiguration(
receivedEmoji: string,
): Promise<CallRoomoteViaEmojiConfiguration | null> {
const automation = await getAutomationRuntime('call_roomote_via_emoji');
const emoji =
typeof automation.settings.emoji === 'string'
? automation.settings.emoji.trim()
: '';

if (
!automation.enabled ||
!emoji ||
!reactionEmojiMatches(emoji, receivedEmoji)
) {
return null;
}

const instructions = automation.instructions?.trim();

return {
emoji,
prompt: instructions
? `${CALL_ROOMOTE_VIA_EMOJI_PROMPT}\n\nAdditional instructions:\n${instructions}`
: CALL_ROOMOTE_VIA_EMOJI_PROMPT,
};
}
133 changes: 133 additions & 0 deletions apps/api/src/handlers/discord/__tests__/index.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading