2023-01-03 23:40:02 -05:00
|
|
|
import config from './config.json' assert {type: "json"};
|
|
|
|
import { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin } from "matrix-bot-sdk";
|
|
|
|
|
|
|
|
const storage = new SimpleFsStorageProvider("storage.json");
|
|
|
|
const client = new MatrixClient(config.homeserver, config.token, storage);
|
|
|
|
|
|
|
|
AutojoinRoomsMixin.setupOnClient(client);
|
2023-01-09 16:04:21 -05:00
|
|
|
client.start().then(() => console.log(`real`));
|
2023-01-03 23:40:02 -05:00
|
|
|
|
|
|
|
client.on("room.message", (roomId, event) => {
|
2023-01-30 13:23:15 -05:00
|
|
|
if (!event["content"] || event["sender"].includes("_bot:")) return;
|
2023-01-04 03:10:33 -05:00
|
|
|
try {
|
|
|
|
if (event["content"]["body"].toLowerCase().includes("real")) {
|
|
|
|
client.replyText(roomId, event, "real")
|
|
|
|
console.table([roomId, event["sender"], event["content"]["body"]])
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Ran into an error:\n" + error)
|
2023-01-03 23:40:02 -05:00
|
|
|
}
|
2023-01-04 03:10:33 -05:00
|
|
|
})
|