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 { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin } from "matrix-bot-sdk";
|
||||
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.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) => {
|
||||
// ? 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;
|
||||
try {
|
||||
if (event["content"]["body"].toLowerCase().includes("real")) {
|
||||
client.replyText(roomId, event, "real")
|
||||
console.table([roomId, event["sender"], event["content"]["body"]])
|
||||
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");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Ran into an error:\n" + error)
|
||||
client.replyNotice(roomId, event, msg);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
363
pnpm-lock.yaml
363
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue