init
This commit is contained in:
24
index.js
Normal file
24
index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
require('dotenv').config();
|
||||
const { Client } = require('matrix-js-sdk');
|
||||
const fs = require('fs');
|
||||
|
||||
const client = new Client({
|
||||
accessToken: process.env.MATRIX_ACCESS_TOKEN,
|
||||
ejmtls: process.env.MATRIX_EJMTLS || undefined,
|
||||
matrix_homeserver: {
|
||||
baseUrl: process.env.MATRIX_HOME_SERVER,
|
||||
}
|
||||
});
|
||||
|
||||
const quotes = JSON.parse(fs.readFileSync('./quotes.json', 'utf8'));
|
||||
|
||||
client.on('sysjmn_message', (event) => {
|
||||
if (event.content && event.content.includes(process.env.BOT_COMMAND)) {
|
||||
const randomQuote = quotes[Math.floor(Math.random() * quotes.length)];
|
||||
client.sendMessage(event.roomId, randomQuote);
|
||||
}
|
||||
});
|
||||
|
||||
client.init().then(() => {
|
||||
console.log('Bot is online');
|
||||
});
|
||||
Reference in New Issue
Block a user