Add forgetting and personality change
This commit is contained in:
parent
6ab8dbd19e
commit
76e496bd38
3 changed files with 103 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import type { MatrixClient } from "matrix-js-sdk";
|
||||
import { config } from "./config.js";
|
||||
import { state } from "./store/store.js";
|
||||
import { type IUser, type TRole } from "./store/types.js";
|
||||
|
|
@ -98,6 +99,28 @@ const getUserFromMention = (mention: string | undefined): IUser | undefined => {
|
|||
return user;
|
||||
};
|
||||
|
||||
const changePersonality = (
|
||||
client: MatrixClient,
|
||||
personalityName: string,
|
||||
): boolean => {
|
||||
const personalityIndex = config.app.ai.personalities.findIndex(
|
||||
(personality) => personality.personalityName === personalityName,
|
||||
);
|
||||
if (personalityIndex === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
state.personality = {
|
||||
index: personalityIndex,
|
||||
startTime: Date.now(),
|
||||
};
|
||||
client.setDisplayName(
|
||||
`AsloBot (${config.app.ai.personalities[state.personality.index]?.personalityName})`,
|
||||
);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export {
|
||||
fixUserData,
|
||||
getUserById,
|
||||
|
|
@ -105,4 +128,5 @@ export {
|
|||
getLevel,
|
||||
getUserName,
|
||||
getUserFromMention,
|
||||
changePersonality,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue