forked from vxmppb/vxmppb
Readding invite code. Send meeting messages to friends, as admin starts it.
Removing second message for failed admin shutdown. Changing status message.
This commit is contained in:
parent
9695b125a2
commit
7f6cbd36a0
48
index.js
48
index.js
|
@ -106,6 +106,9 @@ try {
|
||||||
return directions[index];
|
return directions[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup friends list
|
||||||
|
const friends = Object.keys(config.friends);
|
||||||
|
|
||||||
xmpp.on('online', function(data, to) {
|
xmpp.on('online', function(data, to) {
|
||||||
// once we're online, we'll send a message alerting xmpp admins
|
// once we're online, we'll send a message alerting xmpp admins
|
||||||
console.log('Connected with JID: ' + bot_jid);
|
console.log('Connected with JID: ' + bot_jid);
|
||||||
|
@ -128,8 +131,6 @@ try {
|
||||||
console.log('-------------');
|
console.log('-------------');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// setup friends list
|
|
||||||
const friends = Object.keys(config.friends);
|
|
||||||
// setup gotify url
|
// setup gotify url
|
||||||
let gotifyURL = `${gotify_api_url}/message?token=${gotify_key}&message=${from} ${gotify_message}&title=${gotify_title}&priority=${gotify_priority}`;
|
let gotifyURL = `${gotify_api_url}/message?token=${gotify_key}&message=${from} ${gotify_message}&title=${gotify_title}&priority=${gotify_priority}`;
|
||||||
let gotifyEUrl = encodeURI(gotifyURL);
|
let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
|
@ -429,7 +430,9 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Share-A-Command (#13?)
|
// Share-A-Command which was #13, but kinda turned into a different command
|
||||||
|
// This will generate a private channel, and add the users in the friends
|
||||||
|
// secion from config.ini
|
||||||
else if (message === '!meet') {
|
else if (message === '!meet') {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
|
@ -474,7 +477,7 @@ try {
|
||||||
// loop through friends, authorize users, and send invites
|
// loop through friends, authorize users, and send invites
|
||||||
for (const key in config.friends) {
|
for (const key in config.friends) {
|
||||||
// send xmpp message to friends alerting of new room
|
// send xmpp message to friends alerting of new room
|
||||||
xmpp.send(key, "Meeting started: " + xmpp_muc_name + "@" + xmpp_muc_server);
|
xmpp.send(key, "Meeting started");
|
||||||
// authorize users
|
// authorize users
|
||||||
const addMember = {
|
const addMember = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -491,10 +494,31 @@ try {
|
||||||
},
|
},
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
|
// invite users
|
||||||
|
const inviteMember = {
|
||||||
|
method: 'POST',
|
||||||
|
url: xmpp_api_url + '/send_direct_invitation',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: xmpp_auth
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
name: xmpp_muc_name,
|
||||||
|
service: xmpp_muc_server,
|
||||||
|
password: '',
|
||||||
|
reason: 'vXMPPb Meeting Invite',
|
||||||
|
users: key
|
||||||
|
},
|
||||||
|
json: true
|
||||||
|
};
|
||||||
request(addMember, function(error, response, body) {
|
request(addMember, function(error, response, body) {
|
||||||
if (error) throw new Error(error);
|
if (error) throw new Error(error);
|
||||||
console.log(body);
|
console.log(body);
|
||||||
});
|
});
|
||||||
|
request(inviteMember, function(error, response, body) {
|
||||||
|
if (error) throw new Error(error);
|
||||||
|
console.log(body);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
debug();
|
debug();
|
||||||
|
@ -525,10 +549,8 @@ try {
|
||||||
if (error) throw new Error(error);
|
if (error) throw new Error(error);
|
||||||
console.log(body);
|
console.log(body);
|
||||||
});
|
});
|
||||||
// send meeting ended to user_jid
|
|
||||||
xmpp.send(from, "Meeting ended");
|
|
||||||
// send meeting ended to friends
|
|
||||||
for (const key in config.friends) {
|
for (const key in config.friends) {
|
||||||
|
// alert friends meeting has ended
|
||||||
xmpp.send(key, "Meeting ended");
|
xmpp.send(key, "Meeting ended");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -539,9 +561,7 @@ try {
|
||||||
else if (message === "sudo shutdown now -h") {
|
else if (message === "sudo shutdown now -h") {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, from + " is not in the sudoers file. This incident will be reported.");
|
xmpp.send(from, from + " is not in the sudoers file. This incident will be reported.");
|
||||||
setTimeout(() => {
|
console.log(from + ' tried to shut me down!');
|
||||||
xmpp.send(from, "lol...get it!?");
|
|
||||||
}, 2000);
|
|
||||||
} else {
|
} else {
|
||||||
// send shutdown message
|
// send shutdown message
|
||||||
xmpp.send(from, "Alrighty, shutting down. Goodbye!");
|
xmpp.send(from, "Alrighty, shutting down. Goodbye!");
|
||||||
|
@ -577,7 +597,7 @@ try {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set XMPP status
|
// Set XMPP status
|
||||||
xmpp.setPresence('chat', 'Asterisk,Mastodon, and MQTT. Oh my!');
|
xmpp.setPresence('chat', 'https://vxmppb.tk');
|
||||||
|
|
||||||
// Alas, we connect to XMPP!
|
// Alas, we connect to XMPP!
|
||||||
xmpp.connect({
|
xmpp.connect({
|
||||||
|
@ -587,12 +607,8 @@ try {
|
||||||
port: bot_port
|
port: bot_port
|
||||||
});
|
});
|
||||||
|
|
||||||
// Checks the XMPP server for new 'friend' requests
|
|
||||||
console.log(xmpp.getRoster());
|
|
||||||
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Please create a config.ini");
|
console.log("Please create a config.ini");
|
||||||
console.log("See https://wiki.vanderwarker.family/doku.php?id=code:vxmppb:install:start");
|
console.log("See https://wiki.vanderwarker.family/doku.php?id=code:vxmppb:install:start");
|
||||||
console.log("and choose your prefered install method.")
|
console.log("and choose your prefered install method.");
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user