13 lines
534 B
JavaScript
13 lines
534 B
JavaScript
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.baseUrl, config.token, storage);
|
|
|
|
AutojoinRoomsMixin.setupOnClient(client)
|
|
client.start().then(() => console.log(`Client has started!`));
|
|
|
|
client.on("room.message", (roomId, event) => {
|
|
if (! event["content"] || event["sender"] === config.userId) return;
|
|
// code here
|
|
})
|