diff --git a/index.js b/index.js index e69de29..f493225 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,13 @@ +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 +})