Compare commits

...

3 commits

Author SHA1 Message Date
array-in-a-matrix 7c2a404bc1 real 2023-01-04 00:45:41 -05:00
array-in-a-matrix cc0d55f3f8 ignore matrix storage 2023-01-04 00:45:32 -05:00
array-in-a-matrix 5278e230f3 node dependencies 2023-01-04 00:14:19 -05:00
4 changed files with 1173 additions and 12 deletions

1
.gitignore vendored
View file

@ -132,3 +132,4 @@ dist
# configuration file
config.json
storage.json

View file

@ -5,19 +5,12 @@ const storage = new SimpleFsStorageProvider("storage.json");
const client = new MatrixClient(config.homeserver, config.token, storage);
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) => {
// ? 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 message starts with the bot's <prefix + command> then execute the command
if (event["content"]["body"].toLowerCase().startsWith(config.prefix + "COMMAND")){
//
// TODO: START CODE HERE
//
if (event["content"]["body"].toLowerCase().includes("real")){
client.replyText(roomId, event, "real")
console.log("real => roomId: " + roomId + " author: " + event["sender"] + " message: " + event["content"]["body"] )
}
})
})

6
package.json Normal file
View file

@ -0,0 +1,6 @@
{
"dependencies": {
"matrix-bot-sdk": "^0.6.3"
},
"type": "module"
}

1161
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff