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
|
||||
dist
|
||||
store.json
|
||||
auth.json
|
||||
config.json
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
{"secretKey":"XT0HBMKvfXV9zp8r1CFuIHU4XWLps6qkfabacrxdkNQ="}
|
||||
|
|
@ -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": "!",
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ const onHelp = (_text: string, roomId: string) => {
|
|||
<hr/>
|
||||
<h3>Role: Moderator</h3>
|
||||
<ul>
|
||||
<li><b>!load</b> - Load bot data</li>
|
||||
<li><b>!save</b> - Save bot data</li>
|
||||
<li><b>!loaddata</b> - Load bot data</li>
|
||||
<li><b>!savedata</b> - Save bot data</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<h3>Role: Admin</h3>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue