diff --git a/.gitignore b/.gitignore index b7d0f78..0e50291 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules dist +store.json +auth.json +config.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 diff --git a/src/config.json b/src/config.preset.json similarity index 57% rename from src/config.json rename to src/config.preset.json index dd02bfa..decf090 100644 --- a/src/config.json +++ b/src/config.preset.json @@ -1,11 +1,11 @@ { - "baseUrl": "https://matrix.aslan2142.space", - "userId": "@aslobot:aslan2142.space", + "baseUrl": "https://", + "userId": "@", "authPath": "auth.json", "storePath": "store.json", "auth": { - "accessToken": "mct_iW6Cif22H34s5yAHrmqfBQUsMrGaH2_0QWfYU", - "deviceId": "PBz1Ig9c3p" + "accessToken": "", + "deviceId": "" }, "app": { "triggerPrefix": "!", 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); };