Baphomet is the dedicated bot for nulloctet matrix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

48 lines
1.2 KiB

let sdk = require("matrix-js-sdk");
let config = require("./data/config.json");
console.log("Running with config:");
console.log(config);
let client = sdk.createClient({
baseUrl: config.baseUrl,
accessToken: config.accessToken,
userId: config.userId
});
function createBasicTextMessage(body) {
return {
"body": body,
"msgtype": "m.text"
}
}
function sendClientStatusUpdate() {
config.statusRooms.forEach(roomId => {
console.log("Notifying %s", roomId);
client.sendMessage(roomId, createBasicTextMessage("Started!")).done(function() {
console.log("Notified %s", roomId);
})
});
}
// Prep the bot
client.on("sync", function (state, previousState, data) {
switch (state) {
case "PREPARED":
sendClientStatusUpdate();
break;
}
});
// auto join rooms that an admin user has invited the bot to
client.on("RoomMember.membership", function (event, member) {
if (member.membership === "invite"
&& config.admin.indexOf(ember.userId) >= 0) {
client.joinRoom(member.roomId).done(function () {
console.log("Auto-joined %s", member.roomId);
});
}
});
client.startClient()