From 93ac1a980e0bd90c08bf794065496113c2baf477772fc00d84d18a726f968bb0 Mon Sep 17 00:00:00 2001 From: aslan Date: Tue, 23 Dec 2025 07:56:01 -0500 Subject: [PATCH 1/4] Add auto save and load --- .gitignore | 1 + src/index.ts | 4 ++++ src/modules/base/base.ts | 4 ++-- src/store/store.ts | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b7d0f78..9f6a33d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules dist +store.json diff --git a/src/index.ts b/src/index.ts index 98922ef..a4b86f2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import config from "./config.json" with { type: "json" }; import { MatrixClient, createClient, ClientEvent } from "matrix-js-sdk"; import { registerModules } from "./modules/module.js"; +import { load, save } from "./store/store.js"; let matrixClient: MatrixClient | undefined = undefined; @@ -38,4 +39,7 @@ if (initCode > 0) { process.exit(initCode); } +load(); +setInterval(() => save(), 60000); + listen(); diff --git a/src/modules/base/base.ts b/src/modules/base/base.ts index 9d4fd66..53308db 100644 --- a/src/modules/base/base.ts +++ b/src/modules/base/base.ts @@ -49,8 +49,8 @@ const onHelp = (_text: string, roomId: string) => {

Role: Moderator


Role: Admin

diff --git a/src/store/store.ts b/src/store/store.ts index b35dec9..a892157 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -13,11 +13,15 @@ const load = () => { return; } + console.log("loading data..."); + const json = readFileSync(config.storePath).toString(); state = JSON.parse(json) as IState; }; const save = () => { + console.log("saving data..."); + const json = JSON.stringify(state); writeFileSync(config.storePath, json); }; From e2f14bf73fd323d5773898f682e8036d304f10324bb0e45fc3d89b9e737a9056 Mon Sep 17 00:00:00 2001 From: aslan Date: Tue, 23 Dec 2025 07:56:30 -0500 Subject: [PATCH 2/4] Remove auth --- auth.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 auth.json diff --git a/auth.json b/auth.json deleted file mode 100644 index 18e3f1a..0000000 --- a/auth.json +++ /dev/null @@ -1 +0,0 @@ -{"secretKey":"XT0HBMKvfXV9zp8r1CFuIHU4XWLps6qkfabacrxdkNQ="} \ No newline at end of file From dd1c73000b98f333addf816dae2b133b4338dff0915fc2c215004532104ab95e Mon Sep 17 00:00:00 2001 From: aslan Date: Tue, 23 Dec 2025 07:57:23 -0500 Subject: [PATCH 3/4] Remove config --- .gitignore | 2 ++ src/config.json | 18 ------------------ 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 src/config.json diff --git a/.gitignore b/.gitignore index 9f6a33d..0e50291 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules dist store.json +auth.json +config.json diff --git a/src/config.json b/src/config.json deleted file mode 100644 index dd02bfa..0000000 --- a/src/config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "baseUrl": "https://matrix.aslan2142.space", - "userId": "@aslobot:aslan2142.space", - "authPath": "auth.json", - "storePath": "store.json", - "auth": { - "accessToken": "mct_iW6Cif22H34s5yAHrmqfBQUsMrGaH2_0QWfYU", - "deviceId": "PBz1Ig9c3p" - }, - "app": { - "triggerPrefix": "!", - "experience": { - "gain": 5, - "startingRequirement": 50, - "timeout": 60000 - } - } -} From 1a349cb045ee6a034ad1e234cf35d85bda739feed57eb1dcbf0501f169cd8279 Mon Sep 17 00:00:00 2001 From: aslan Date: Tue, 23 Dec 2025 07:58:26 -0500 Subject: [PATCH 4/4] Add config preset --- src/config.preset.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/config.preset.json diff --git a/src/config.preset.json b/src/config.preset.json new file mode 100644 index 0000000..decf090 --- /dev/null +++ b/src/config.preset.json @@ -0,0 +1,18 @@ +{ + "baseUrl": "https://", + "userId": "@", + "authPath": "auth.json", + "storePath": "store.json", + "auth": { + "accessToken": "", + "deviceId": "" + }, + "app": { + "triggerPrefix": "!", + "experience": { + "gain": 5, + "startingRequirement": 50, + "timeout": 60000 + } + } +}