Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
Stephen Vanderwarker | cf0dc7c93a | |
Stephen Vanderwarker | 03883a3030 | |
Stephen Vanderwarker | bf06259369 | |
Stephen Vanderwarker | 6a40b9a119 | |
Stephen Vanderwarker | 0ae55d2262 | |
Stephen Vanderwarker | da3390bc89 |
|
@ -1,8 +1,6 @@
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
config.ini
|
|
||||||
build/
|
build/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
.vs/
|
.vs/
|
||||||
Dockerfile
|
Dockerfile
|
||||||
Jenkinsfile
|
|
||||||
|
|
|
@ -3,5 +3,6 @@ package-lock.json
|
||||||
config.ini
|
config.ini
|
||||||
build/
|
build/
|
||||||
.npmignore
|
.npmignore
|
||||||
|
.dockerignore
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
.vs/
|
.vs/
|
||||||
|
|
|
@ -4,14 +4,6 @@ Vanderwarker Family XMPP Bot.
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
[![NPM](https://nodei.co/npm/vxmppb.png?compact=true)](https://nodei.co/npm/vxmppb/)
|
|
||||||
|
|
||||||
[![Known Vulnerabilities](https://snyk.io/test/npm/vxmppb/badge.svg)](https://snyk.io/test/npm/vxmppb)
|
|
||||||
|
|
||||||
![docker](https://img.shields.io/docker/pulls/vxmppb/vxmppb.svg)
|
|
||||||
|
|
||||||
![npm](https://img.shields.io/npm/dt/vxmppb)
|
|
||||||
|
|
||||||
### :book: How To Install
|
### :book: How To Install
|
||||||
You can install using:
|
You can install using:
|
||||||
- [npm](https://wiki.vanderwarker.family/doku.php?id=code:vxmppb:install:npm)
|
- [npm](https://wiki.vanderwarker.family/doku.php?id=code:vxmppb:install:npm)
|
||||||
|
|
110
index.js
110
index.js
|
@ -280,7 +280,7 @@ try {
|
||||||
});
|
});
|
||||||
debug();
|
debug();
|
||||||
}
|
}
|
||||||
} else if (message === '!lightsauth') {
|
} else if (message === '!reauth') {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -446,100 +446,26 @@ try {
|
||||||
// Please note this section requires you to have an Ejabberd server.
|
// Please note this section requires you to have an Ejabberd server.
|
||||||
// I am welcome to pull requests for other servers (maybe set type in config.ini)
|
// I am welcome to pull requests for other servers (maybe set type in config.ini)
|
||||||
else if (message === '!meet') {
|
else if (message === '!meet') {
|
||||||
|
console.log(xmpp_server_type);
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
} else {
|
} else {
|
||||||
if (xmpp_server_type === "ejabberd"){
|
if (xmpp_server_type === "ejabberd"){
|
||||||
// Create private XMPP room
|
fs.readFileSync('./servers/ejabberd.js', 'utf-8');
|
||||||
const createRoom = {
|
console.log("server type is ejabberd");
|
||||||
method: 'POST',
|
debug();
|
||||||
url: xmpp_api_url + '/create_room_with_opts',
|
xmpp.send(from, "Alright. Starting a new meeting: " + xmpp_muc_name + "@" + xmpp_muc_server + " and inviting friends");
|
||||||
headers: {
|
}
|
||||||
'Content-Type': 'application/json',
|
else if (xmpp_server_type === "prosidy"){
|
||||||
Authorization: xmpp_auth
|
xmpp.send(from, "Ejabberd is the only supported server at the moment.")
|
||||||
},
|
xmpp.send(from, "Please see https://git.vanderwarker.family/vxmppb/vxmppb/issues/20")
|
||||||
body: {
|
}
|
||||||
name: xmpp_muc_name,
|
else if (xmpp_server_type === "openfire"){
|
||||||
service: xmpp_muc_server,
|
// fs.readFileSync('./servers/openfire.js', 'utf-8');
|
||||||
host: bot_hostname,
|
xmpp.send(from, "Ejabberd is the only supported server at the moment.")
|
||||||
options: {
|
xmpp.send(from, "Please see https://git.vanderwarker.family/vxmppb/vxmppb/issues/20")
|
||||||
allow_change_subj: 'false',
|
}
|
||||||
allow_private_messages: 'false',
|
}
|
||||||
allow_private_messages_from_visitors: 'false',
|
|
||||||
allow_visitor_nickchange: 'false',
|
|
||||||
allow_visitor_status: 'false',
|
|
||||||
lang: 'en',
|
|
||||||
mam: 'true',
|
|
||||||
members_only: 'true',
|
|
||||||
persistent: 'false',
|
|
||||||
public: 'false',
|
|
||||||
public_list: 'false',
|
|
||||||
title: 'Secure channel generated by https://vxmppb.tk',
|
|
||||||
allow_subscription: 'true'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
json: true
|
|
||||||
};
|
|
||||||
// send request to create room
|
|
||||||
request(createRoom, function (error, response, body) {
|
|
||||||
if (error) throw new Error(error);
|
|
||||||
console.log(body);
|
|
||||||
});
|
|
||||||
// wait 2 seconds until room has been created (http issues)
|
|
||||||
setTimeout(() => {
|
|
||||||
// loop through friends, authorize users, and send invites
|
|
||||||
for (const key in config.friends) {
|
|
||||||
// send xmpp message to friends alerting of new room
|
|
||||||
xmpp.send(key, "Meeting started");
|
|
||||||
// authorize users
|
|
||||||
const addMember = {
|
|
||||||
method: 'POST',
|
|
||||||
url: xmpp_api_url + 'set_room_affiliation',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Authorization: xmpp_auth
|
|
||||||
},
|
|
||||||
body: {
|
|
||||||
name: xmpp_muc_name,
|
|
||||||
service: xmpp_muc_server,
|
|
||||||
jid: key,
|
|
||||||
affiliation: 'member'
|
|
||||||
},
|
|
||||||
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) {
|
|
||||||
if (error) throw new Error(error);
|
|
||||||
console.log(body);
|
|
||||||
});
|
|
||||||
request(inviteMember, function (error, response, body) {
|
|
||||||
if (error) throw new Error(error);
|
|
||||||
console.log(body);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
debug();
|
|
||||||
xmpp.send(from, "Alright. Starting a new meeting: " + xmpp_muc_name + "@" + xmpp_muc_server + " and inviting friends");
|
|
||||||
} else {
|
|
||||||
xmpp.send(from, "Ejabberd is the only supported server at the moment.")
|
|
||||||
xmpp.send(from, "Please see https://git.vanderwarker.family/vxmppb/vxmppb/issues/20")
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// End meeting
|
// End meeting
|
||||||
|
@ -649,4 +575,4 @@ try {
|
||||||
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.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
const createRoom = {
|
||||||
|
method: 'POST',
|
||||||
|
url: xmpp_api_url + '/create_room_with_opts',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: xmpp_auth
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
name: xmpp_muc_name,
|
||||||
|
service: xmpp_muc_server,
|
||||||
|
host: bot_hostname,
|
||||||
|
options: {
|
||||||
|
allow_change_subj: 'false',
|
||||||
|
allow_private_messages: 'false',
|
||||||
|
allow_private_messages_from_visitors: 'false',
|
||||||
|
allow_visitor_nickchange: 'false',
|
||||||
|
allow_visitor_status: 'false',
|
||||||
|
lang: 'en',
|
||||||
|
mam: 'true',
|
||||||
|
members_only: 'true',
|
||||||
|
persistent: 'false',
|
||||||
|
public: 'false',
|
||||||
|
public_list: 'false',
|
||||||
|
title: 'Secure channel generated by https://vxmppb.tk',
|
||||||
|
allow_subscription: 'true'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
json: true
|
||||||
|
};
|
||||||
|
|
||||||
|
// send request to create room
|
||||||
|
request(createRoom, function (error, response, body) {
|
||||||
|
if (error) throw new Error(error);
|
||||||
|
console.log(body);
|
||||||
|
});
|
||||||
|
// wait 2 seconds until room has been created (http issues)
|
||||||
|
setTimeout(() => {
|
||||||
|
// loop through friends, authorize users, and send invites
|
||||||
|
for (const key in config.friends) {
|
||||||
|
// send xmpp message to friends alerting of new room
|
||||||
|
xmpp.send(key, "Meeting started");
|
||||||
|
// authorize users
|
||||||
|
const addMember = {
|
||||||
|
method: 'POST',
|
||||||
|
url: xmpp_api_url + 'set_room_affiliation',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: xmpp_auth
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
name: xmpp_muc_name,
|
||||||
|
service: xmpp_muc_server,
|
||||||
|
jid: key,
|
||||||
|
affiliation: 'member'
|
||||||
|
},
|
||||||
|
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) {
|
||||||
|
if (error) throw new Error(error);
|
||||||
|
console.log(body);
|
||||||
|
});
|
||||||
|
request(inviteMember, function (error, response, body) {
|
||||||
|
if (error) throw new Error(error);
|
||||||
|
console.log(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 2000);
|
|
@ -0,0 +1,30 @@
|
||||||
|
const createRoom = {
|
||||||
|
method: 'POST',
|
||||||
|
// This requires to install a plugin! Please check list on openfire
|
||||||
|
// admin dashboard. Search for HTTP API
|
||||||
|
url: xmpp_api_url + '/plugins/restapi/v1/chatrooms',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: xmpp_auth
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
options: {
|
||||||
|
roomName: xmpp_muc_name,
|
||||||
|
naturalName: xmpp_muc_name,
|
||||||
|
description: "Secure channel generated by https://vxmppb.tk",
|
||||||
|
subject: "Secure channel generated by https://vxmppb.tk",
|
||||||
|
persistent: "false",
|
||||||
|
publicRoom: "false",
|
||||||
|
registrationEnabled: "false",
|
||||||
|
canOccupantsChangeSubject: "false",
|
||||||
|
membersOnly: "true",
|
||||||
|
moderated: "true",
|
||||||
|
members: {
|
||||||
|
// Member!? MEMBER?!? Ooo ooo! Member?!
|
||||||
|
"member": [
|
||||||
|
config.friends
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
const createRoom = {
|
||||||
|
method: 'GET',
|
||||||
|
url: xmpp_api_url + '/muc/config?jid=' + user_jid,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: xmpp_auth
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
name: xmpp_muc_name,
|
||||||
|
service: xmpp_muc_server,
|
||||||
|
host: bot_hostname,
|
||||||
|
options: {
|
||||||
|
affliations: [
|
||||||
|
{
|
||||||
|
affliation: "member",
|
||||||
|
jid: config.friends,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
config: {
|
||||||
|
description: "",
|
||||||
|
members_only: true,
|
||||||
|
moderated: true,
|
||||||
|
name: xmpp_muc_name,
|
||||||
|
persistent: false,
|
||||||
|
subject: "Secure channel generated by https://vxmppb.tk",
|
||||||
|
public: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue