Compare commits

...

8 Commits
main ... meow

Author SHA1 Message Date
array-in-a-matrix f27c772835 fix regex 2023-11-06 22:44:37 -05:00
array-in-a-matrix c86d97b940 dep 2023-11-06 13:56:42 -05:00
array-in-a-matrix 22107c725b overhaul 2023-11-06 13:56:32 -05:00
array-in-a-matrix 601ef76759 meow 2023-01-31 16:14:01 -05:00
array-in-a-matrix 506b38faee Update 'index.js' 2023-01-30 13:23:52 -05:00
array-in-a-matrix 6606983915 meow 2023-01-27 10:19:10 -05:00
array-in-a-matrix 4df2500be6 meow
meow
2023-01-27 09:53:36 -05:00
array-in-a-matrix c987b538e8 meow
meow
2023-01-27 09:53:04 -05:00
3 changed files with 204 additions and 192 deletions

View File

@ -1,3 +1,3 @@
# real
# meow
real
meow

View File

@ -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);
}
})
});

File diff suppressed because it is too large Load Diff