Compare commits

...

4 commits

Author SHA256 Message Date
1a349cb045 Add config preset 2025-12-23 07:58:26 -05:00
dd1c73000b Remove config 2025-12-23 07:57:23 -05:00
e2f14bf73f Remove auth 2025-12-23 07:56:30 -05:00
93ac1a980e Add auto save and load 2025-12-23 07:56:01 -05:00
6 changed files with 17 additions and 7 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
node_modules node_modules
dist dist
store.json
auth.json
config.json

View file

@ -1 +0,0 @@
{"secretKey":"XT0HBMKvfXV9zp8r1CFuIHU4XWLps6qkfabacrxdkNQ="}

View file

@ -1,11 +1,11 @@
{ {
"baseUrl": "https://matrix.aslan2142.space", "baseUrl": "https://",
"userId": "@aslobot:aslan2142.space", "userId": "@",
"authPath": "auth.json", "authPath": "auth.json",
"storePath": "store.json", "storePath": "store.json",
"auth": { "auth": {
"accessToken": "mct_iW6Cif22H34s5yAHrmqfBQUsMrGaH2_0QWfYU", "accessToken": "",
"deviceId": "PBz1Ig9c3p" "deviceId": ""
}, },
"app": { "app": {
"triggerPrefix": "!", "triggerPrefix": "!",

View file

@ -2,6 +2,7 @@ import config from "./config.json" with { type: "json" };
import { MatrixClient, createClient, ClientEvent } from "matrix-js-sdk"; import { MatrixClient, createClient, ClientEvent } from "matrix-js-sdk";
import { registerModules } from "./modules/module.js"; import { registerModules } from "./modules/module.js";
import { load, save } from "./store/store.js";
let matrixClient: MatrixClient | undefined = undefined; let matrixClient: MatrixClient | undefined = undefined;
@ -38,4 +39,7 @@ if (initCode > 0) {
process.exit(initCode); process.exit(initCode);
} }
load();
setInterval(() => save(), 60000);
listen(); listen();

View file

@ -49,8 +49,8 @@ const onHelp = (_text: string, roomId: string) => {
<hr/> <hr/>
<h3>Role: Moderator</h3> <h3>Role: Moderator</h3>
<ul> <ul>
<li><b>!load</b> - Load bot data</li> <li><b>!loaddata</b> - Load bot data</li>
<li><b>!save</b> - Save bot data</li> <li><b>!savedata</b> - Save bot data</li>
</ul> </ul>
<hr/> <hr/>
<h3>Role: Admin</h3> <h3>Role: Admin</h3>

View file

@ -13,11 +13,15 @@ const load = () => {
return; return;
} }
console.log("loading data...");
const json = readFileSync(config.storePath).toString(); const json = readFileSync(config.storePath).toString();
state = JSON.parse(json) as IState; state = JSON.parse(json) as IState;
}; };
const save = () => { const save = () => {
console.log("saving data...");
const json = JSON.stringify(state); const json = JSON.stringify(state);
writeFileSync(config.storePath, json); writeFileSync(config.storePath, json);
}; };