Add ai functionality
This commit is contained in:
parent
da66cf9001
commit
dd4da06753
19 changed files with 1118 additions and 52 deletions
|
|
@ -12,35 +12,41 @@ const registerModuleAdmin = (
|
|||
client = matrixClient;
|
||||
|
||||
callbackStore.messageCallbacks.push({
|
||||
startCondition: `${config.app.triggerPrefix}shutdown`,
|
||||
startConditions: [`${config.app.triggerPrefix}shutdown`],
|
||||
allowedRoles: ["ADMIN"],
|
||||
callbackFunc: onShutdown,
|
||||
});
|
||||
callbackStore.messageCallbacks.push({
|
||||
startCondition: `${config.app.triggerPrefix}loaddata`,
|
||||
startConditions: [`${config.app.triggerPrefix}loaddata`],
|
||||
allowedRoles: ["MODERATOR", "ADMIN"],
|
||||
callbackFunc: onLoadData,
|
||||
});
|
||||
callbackStore.messageCallbacks.push({
|
||||
startCondition: `${config.app.triggerPrefix}savedata`,
|
||||
startConditions: [`${config.app.triggerPrefix}savedata`],
|
||||
allowedRoles: ["MODERATOR", "ADMIN"],
|
||||
callbackFunc: onSaveData,
|
||||
});
|
||||
};
|
||||
|
||||
const onShutdown = (text: string) => {
|
||||
const onShutdown = (text: string, roomId: string) => {
|
||||
if (!text.includes("nosave")) {
|
||||
client.sendTextMessage(roomId, "Saving data...");
|
||||
save();
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
const sendPromise = client.sendTextMessage(roomId, "Shutting down...");
|
||||
sendPromise.finally(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
};
|
||||
|
||||
const onLoadData = () => {
|
||||
const onLoadData = (_text: string, roomId: string) => {
|
||||
client.sendTextMessage(roomId, "Loading data...");
|
||||
load();
|
||||
};
|
||||
|
||||
const onSaveData = () => {
|
||||
const onSaveData = (_text: string, roomId: string) => {
|
||||
client.sendTextMessage(roomId, "Saving data...");
|
||||
save();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue