spammy-matrix-bots/index.js
array-in-a-matrix 601ef76759 meow
2023-01-31 16:14:01 -05:00

26 lines
937 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.homeserver, config.token, storage);
AutojoinRoomsMixin.setupOnClient(client);
client.start().then(() => console.log(`meow`));
client.on("room.message", (roomId, event) => {
if (!event["content"] || event["sender"].includes("_bot:")) return;
try {
if (event["content"]["body"].toLowerCase().includes("meow")) {
let msg="meow";
while(Math.floor(Math.random() * 5)){
msg = msg.concat(" meow")
}
client.replyText(roomId, event, msg)
console.table([roomId, event["sender"], event["content"]["body"]])
}
} catch (error) {
console.error("Ran into an error:\n" + error)
}
})