Add emote reactions
This commit is contained in:
parent
a8e1a83e63
commit
6ab8dbd19e
6 changed files with 45 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ const onAI = async (
|
|||
text: string,
|
||||
roomId: string,
|
||||
sender: string,
|
||||
eventId: string,
|
||||
repliedMessage?: string,
|
||||
repliedSender?: string,
|
||||
image?: Buffer<ArrayBuffer>,
|
||||
|
|
@ -82,6 +83,7 @@ const onAI = async (
|
|||
const responseAI = await getTextGemini(
|
||||
{
|
||||
client: client,
|
||||
eventId: eventId,
|
||||
roomId: roomId,
|
||||
sender: sender,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ const registerModules = (client: MatrixClient) => {
|
|||
|
||||
const roomId = event.getRoomId();
|
||||
const sender = event.getSender();
|
||||
if (!roomId || !sender) {
|
||||
const eventId = event.getId();
|
||||
if (!roomId || !sender || !eventId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -145,6 +146,7 @@ const registerModules = (client: MatrixClient) => {
|
|||
body.toString(),
|
||||
roomId,
|
||||
sender,
|
||||
eventId,
|
||||
repliedMessage,
|
||||
repliedSender,
|
||||
image,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ interface ICallback {
|
|||
text: string,
|
||||
roomId: string,
|
||||
sender: string,
|
||||
eventId: string,
|
||||
repliedMessage?: string,
|
||||
repliedSender?: string,
|
||||
image?: Buffer<ArrayBuffer>,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import type { FunctionDeclaration } from "@google/genai";
|
|||
import { config, packageConfig } from "../../config.js";
|
||||
import type { AIToolFunction } from "./types.js";
|
||||
import { save, state } from "../../store/store.js";
|
||||
import { EventType, RelationType } from "matrix-js-sdk";
|
||||
|
||||
const tools: FunctionDeclaration[] = [
|
||||
{
|
||||
|
|
@ -27,6 +28,20 @@ const tools: FunctionDeclaration[] = [
|
|||
required: ["password"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sendReaction",
|
||||
description: "Sends an emoji reaction to user's message",
|
||||
parametersJsonSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
emoji: {
|
||||
type: "string",
|
||||
description: "one emoji to react with (example: 😀)",
|
||||
},
|
||||
},
|
||||
required: ["emoji"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "remember",
|
||||
description: "Gets information about this AI bot",
|
||||
|
|
@ -97,6 +112,28 @@ const toolFunctions: AIToolFunction[] = [
|
|||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sendReaction",
|
||||
function: async (matrix, args) => {
|
||||
if (args.emoji) {
|
||||
await matrix.client.sendEvent(
|
||||
matrix.roomId,
|
||||
EventType.Reaction,
|
||||
{
|
||||
"m.relates_to": {
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: matrix.eventId,
|
||||
key: args.emoji,
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
message: "success",
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "remember",
|
||||
function: (_matrix, args) => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ interface AIToolMatrixData {
|
|||
client: MatrixClient;
|
||||
roomId: string;
|
||||
sender: string;
|
||||
eventId: string;
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue