created template
This commit is contained in:
parent
8e3e94b190
commit
bcb37278e1
7
example.config.json
Normal file
7
example.config.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"homeserver": "<DOMAIN.TLD>",
|
||||||
|
"token": "<TOKEN>",
|
||||||
|
"user": "@<USER>:<DOMAIN.TLD>",
|
||||||
|
"prefix": "!",
|
||||||
|
}
|
||||||
|
|
23
index.js
Normal file
23
index.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import config from './config.json' assert {type: "json"};
|
||||||
|
import { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin } 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(`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;
|
||||||
|
// ? 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
|
||||||
|
//
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue