generated from array-in-a-matrix/matrix-bot-template
Compare commits
3 commits
5ea33abf21
...
894700edd5
Author | SHA1 | Date | |
---|---|---|---|
894700edd5 | |||
4e8c2a6574 | |||
82eaae1d02 |
|
@ -2,6 +2,7 @@
|
|||
"homeserver": "https://<DOMAIN.TLD>",
|
||||
"token": "<TOKEN>",
|
||||
"user": "@<USER>:<DOMAIN.TLD>",
|
||||
"prefix": "!",
|
||||
"time": "<HOUR>",
|
||||
"key": "<PREFIX>"
|
||||
}
|
||||
|
||||
|
|
20
index.js
20
index.js
|
@ -5,19 +5,15 @@ 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(`Vanishing messages...`));
|
||||
|
||||
let timeInMS = config.time * 3_600_000 //? converts hours to milliseconds
|
||||
|
||||
// ? 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["sender"] === config.user) {
|
||||
if (event["content"]["body"].startsWith(config.key)) return; //? if message starts with the key do NOT delete that message
|
||||
console.table([roomId, event["content"]["body"]])
|
||||
function redactMessage(){client.redactEvent(roomId, event["event_id"], "Vanish")} //? define callback function
|
||||
setTimeout(redactMessage, timeInMS)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
6
package.json
Normal file
6
package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"matrix-bot-sdk": "^0.6.3"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
1161
pnpm-lock.yaml
Normal file
1161
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue