Add emote reactions
This commit is contained in:
parent
a8e1a83e63
commit
6ab8dbd19e
6 changed files with 45 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "aslobot-matrix",
|
"name": "aslobot-matrix",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ const onAI = async (
|
||||||
text: string,
|
text: string,
|
||||||
roomId: string,
|
roomId: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
|
eventId: string,
|
||||||
repliedMessage?: string,
|
repliedMessage?: string,
|
||||||
repliedSender?: string,
|
repliedSender?: string,
|
||||||
image?: Buffer<ArrayBuffer>,
|
image?: Buffer<ArrayBuffer>,
|
||||||
|
|
@ -82,6 +83,7 @@ const onAI = async (
|
||||||
const responseAI = await getTextGemini(
|
const responseAI = await getTextGemini(
|
||||||
{
|
{
|
||||||
client: client,
|
client: client,
|
||||||
|
eventId: eventId,
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,8 @@ const registerModules = (client: MatrixClient) => {
|
||||||
|
|
||||||
const roomId = event.getRoomId();
|
const roomId = event.getRoomId();
|
||||||
const sender = event.getSender();
|
const sender = event.getSender();
|
||||||
if (!roomId || !sender) {
|
const eventId = event.getId();
|
||||||
|
if (!roomId || !sender || !eventId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,6 +146,7 @@ const registerModules = (client: MatrixClient) => {
|
||||||
body.toString(),
|
body.toString(),
|
||||||
roomId,
|
roomId,
|
||||||
sender,
|
sender,
|
||||||
|
eventId,
|
||||||
repliedMessage,
|
repliedMessage,
|
||||||
repliedSender,
|
repliedSender,
|
||||||
image,
|
image,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ interface ICallback {
|
||||||
text: string,
|
text: string,
|
||||||
roomId: string,
|
roomId: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
|
eventId: string,
|
||||||
repliedMessage?: string,
|
repliedMessage?: string,
|
||||||
repliedSender?: string,
|
repliedSender?: string,
|
||||||
image?: Buffer<ArrayBuffer>,
|
image?: Buffer<ArrayBuffer>,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import type { FunctionDeclaration } from "@google/genai";
|
||||||
import { config, packageConfig } from "../../config.js";
|
import { config, packageConfig } from "../../config.js";
|
||||||
import type { AIToolFunction } from "./types.js";
|
import type { AIToolFunction } from "./types.js";
|
||||||
import { save, state } from "../../store/store.js";
|
import { save, state } from "../../store/store.js";
|
||||||
|
import { EventType, RelationType } from "matrix-js-sdk";
|
||||||
|
|
||||||
const tools: FunctionDeclaration[] = [
|
const tools: FunctionDeclaration[] = [
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +28,20 @@ const tools: FunctionDeclaration[] = [
|
||||||
required: ["password"],
|
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",
|
name: "remember",
|
||||||
description: "Gets information about this AI bot",
|
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",
|
name: "remember",
|
||||||
function: (_matrix, args) => {
|
function: (_matrix, args) => {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ interface AIToolMatrixData {
|
||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
roomId: string;
|
roomId: string;
|
||||||
sender: string;
|
sender: string;
|
||||||
|
eventId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue