Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
f27c772835 | |||
c86d97b940 | |||
22107c725b | |||
601ef76759 | |||
array-in-a-matrix | 506b38faee | ||
array-in-a-matrix | 6606983915 | ||
array-in-a-matrix | 4df2500be6 | ||
array-in-a-matrix | c987b538e8 |
29
index.js
29
index.js
|
@ -1,20 +1,29 @@
|
||||||
import config from './config.json' assert {type: "json"};
|
import config from "./config.json" assert { type: "json" };
|
||||||
import { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin } from "matrix-bot-sdk";
|
import {
|
||||||
|
MatrixClient,
|
||||||
|
SimpleFsStorageProvider,
|
||||||
|
AutojoinRoomsMixin,
|
||||||
|
RichRepliesPreprocessor,
|
||||||
|
} from "matrix-bot-sdk";
|
||||||
|
|
||||||
const storage = new SimpleFsStorageProvider("storage.json");
|
const storage = new SimpleFsStorageProvider("storage.json");
|
||||||
const client = new MatrixClient(config.homeserver, config.token, storage);
|
const client = new MatrixClient(config.homeserver, config.token, storage);
|
||||||
|
|
||||||
AutojoinRoomsMixin.setupOnClient(client);
|
AutojoinRoomsMixin.setupOnClient(client);
|
||||||
client.start().then(() => console.log(`real`));
|
client.addPreprocessor(new RichRepliesPreprocessor(false));
|
||||||
|
client.start().then(() => console.log(`Client has started!`));
|
||||||
|
|
||||||
|
// ? event listener
|
||||||
client.on("room.message", (roomId, event) => {
|
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;
|
if (!event["content"] || event["sender"] === config.user) return;
|
||||||
try {
|
const message = event["content"]["body"].toLowerCase();
|
||||||
if (event["content"]["body"].toLowerCase().includes("real")) {
|
|
||||||
client.replyText(roomId, event, "real")
|
if (message.match(/m*.e*.o*.w/gi)) {
|
||||||
console.table([roomId, event["sender"], event["content"]["body"]])
|
let msg = "meow";
|
||||||
|
while (Math.floor(Math.random() * 5)) {
|
||||||
|
msg = msg.concat(" meow");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
client.replyNotice(roomId, event, msg);
|
||||||
console.error("Ran into an error:\n" + error)
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
363
pnpm-lock.yaml
363
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue