Compare commits
4 commits
9cabbc8813
...
1a349cb045
| Author | SHA256 | Date | |
|---|---|---|---|
| 1a349cb045 | |||
| dd1c73000b | |||
| e2f14bf73f | |||
| 93ac1a980e |
6 changed files with 17 additions and 7 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,2 +1,5 @@
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
store.json
|
||||||
|
auth.json
|
||||||
|
config.json
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"secretKey":"XT0HBMKvfXV9zp8r1CFuIHU4XWLps6qkfabacrxdkNQ="}
|
|
||||||
|
|
@ -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": "!",
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue