import config from "./config.json" assert { type: "json" }; import { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin, RichRepliesPreprocessor, } from "matrix-bot-sdk"; const storage = new SimpleFsStorageProvider("storage.json"); const client = new MatrixClient(config.homeserver, config.token, storage); AutojoinRoomsMixin.setupOnClient(client); client.addPreprocessor(new RichRepliesPreprocessor(false)); client.start().then(() => console.log(`Client has started!`)); // ? event listener client.on("room.message", (roomId, event) => { // ? check if the message's text is not empty and isn't sent by the bot itself if (!event["content"] || event["sender"] === config.user) return; const message = event["content"]["body"].toLowerCase(); if (message.match(/m*.e*.o*.w/gi)) { let msg = "meow"; while (Math.floor(Math.random() * 5)) { msg = msg.concat(" meow"); } client.replyNotice(roomId, event, msg); } });