From e46c4427ccb4aef4d36a00123910a6a9d6bcae4b90eb775896c387b3be110a0d Mon Sep 17 00:00:00 2001 From: aslan Date: Sun, 28 Dec 2025 19:11:32 +0100 Subject: [PATCH] Update ai information --- package.json | 2 +- src/modules/ai/ai.ts | 8 ++++++-- src/modules/ai/alts.ts | 6 ------ src/modules/ai/types.ts | 2 +- src/modules/base/base.ts | 3 ++- src/modules/user/user.ts | 20 ++++++++++++++++++++ src/store/types.ts | 1 + 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 858a672..bf497c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aslobot-matrix", - "version": "0.7.1", + "version": "0.7.2", "description": "", "license": "ISC", "author": "", diff --git a/src/modules/ai/ai.ts b/src/modules/ai/ai.ts index 8743b21..d5d4d2c 100644 --- a/src/modules/ai/ai.ts +++ b/src/modules/ai/ai.ts @@ -3,7 +3,7 @@ import type { ICallbackStore } from "../types.js"; import { config } from "../../config.js"; import { getTextGemini, getImageGemini } from "../../services/ai/ai.js"; import { alts } from "./alts.js"; -import type { IAdminInstructions } from "./types.js"; +import type { IAdminInstructions, IAIAlt } from "./types.js"; import { getUserById, getUserName } from "../../helpers.js"; import { prices } from "./prices.js"; @@ -38,7 +38,11 @@ const onAI = async (text: string, roomId: string, sender: string) => { let instructions = { prefferedLanguages: ["english", "slovak"], adminText: config.app.ai.prompt, - alts: alts, + alts: alts.map((alt) => ({ + keys: alt.keys, + alt: alt.alt, + information: user.information, + })), } as IAdminInstructions; const username = getUserName(user); diff --git a/src/modules/ai/alts.ts b/src/modules/ai/alts.ts index 6a162d2..f7b8ead 100644 --- a/src/modules/ai/alts.ts +++ b/src/modules/ai/alts.ts @@ -16,17 +16,14 @@ const alts: IAIAlt[] = [ "macag", ], alt: "black cat", - information: "an evil cat, married to white cat", }, { keys: ["macica", "macico"], alt: "white cat", - information: "married to black cat", }, { keys: ["gabor", "gaber", "martin", "marting"], alt: "hedgehog", - information: "married to ai", }, { keys: [ @@ -40,17 +37,14 @@ const alts: IAIAlt[] = [ "madek", ], alt: "beaver", - information: "likes shoot fetish", }, { keys: ["janys", "jano", "janeg", "janek", "aslanek", "aslan", "aslo"], alt: "lion", - information: "the creator", }, { keys: ["marek", "mareg", "macek", "maceg", "rod"], alt: "purple snake", - information: "drives fast", }, { keys: ["lara", "kostur", "kosturik"], diff --git a/src/modules/ai/types.ts b/src/modules/ai/types.ts index 1189939..6fbe64e 100644 --- a/src/modules/ai/types.ts +++ b/src/modules/ai/types.ts @@ -1,7 +1,7 @@ interface IAIAlt { keys: string[]; alt: string; - information?: string; + information?: string | undefined; } interface IAdminInstructions { diff --git a/src/modules/base/base.ts b/src/modules/base/base.ts index 2e119bb..d406df5 100644 --- a/src/modules/base/base.ts +++ b/src/modules/base/base.ts @@ -68,7 +68,8 @@ const onHelp = (_text: string, roomId: string) => {
  • !say {text} - Repeats your message
  • !bowling {text} - Repeats your message in bowling
  • !help - Prints this help message
  • -
  • !me / !me {mention} - Prints your role, level, experience, money and ai cost
  • +
  • !me / !me {mention} - Prints data about you
  • +
  • !myinfo {newinfo} - Updates your description
  • !leaderboard - Prints total user ranking
  • !aileaderboard - Prints total user ai cost
  • diff --git a/src/modules/user/user.ts b/src/modules/user/user.ts index 5874f70..502891e 100644 --- a/src/modules/user/user.ts +++ b/src/modules/user/user.ts @@ -21,6 +21,10 @@ const registerModuleUser = ( startConditions: [`${config.app.triggerPrefix}me`], callbackFunc: onMe, }); + callbackStore.messageCallbacks.push({ + startConditions: [`${config.app.triggerPrefix}myinfo `], + callbackFunc: onMyInfo, + }); callbackStore.messageCallbacks.push({ startConditions: [`${config.app.triggerPrefix}leaderboard`], callbackFunc: onLeaderboard, @@ -51,6 +55,22 @@ const onMe = (text: string, roomId: string, sender: string) => { ); }; +const onMyInfo = (text: string, roomId: string, sender: string) => { + const user = getUserById(sender); + const newInformation = text.replace( + `${config.app.triggerPrefix}myinfo `, + "", + ); + + if (!user || newInformation.length < 3) { + return; + } + + user.information = newInformation; + + client.sendTextMessage(roomId, "Information updated"); +}; + const onLeaderboard = (_text: string, roomId: string) => { const mapUsersToLeaderboard = (user: IUser): string => { const level = getLevel(user.experience); diff --git a/src/store/types.ts b/src/store/types.ts index 3c07f19..2af1ecc 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -4,6 +4,7 @@ interface IState { interface IUser { id: string; + information?: string; role: TRole; experience: number; money: number;