real
This commit is contained in:
parent
cc0d55f3f8
commit
7c2a404bc1
17
index.js
17
index.js
|
@ -5,19 +5,12 @@ 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(`Client has started!`));
|
client.start().then(() => console.log(`Client has entered the matrix!`));
|
||||||
|
|
||||||
// ? 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;
|
||||||
// ? if message starts with the bot's <prefix + command> then execute the command
|
if (event["content"]["body"].toLowerCase().includes("real")){
|
||||||
if (event["content"]["body"].toLowerCase().startsWith(config.prefix + "COMMAND")){
|
client.replyText(roomId, event, "real")
|
||||||
|
console.log("real => roomId: " + roomId + " author: " + event["sender"] + " message: " + event["content"]["body"] )
|
||||||
//
|
|
||||||
// TODO: START CODE HERE
|
|
||||||
//
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue