forked from vxmppb/vxmppb
Reviewed-on: vxmppb/vxmppb#18
This commit is contained in:
commit
3598bd5082
56
index.js
56
index.js
|
@ -100,7 +100,9 @@ xmpp.on('online', function(data, to) {
|
||||||
console.log('Connected with JID: ' + bot_jid);
|
console.log('Connected with JID: ' + bot_jid);
|
||||||
xmpp.send(user_jid, "[ONLINE]", false);
|
xmpp.send(user_jid, "[ONLINE]", false);
|
||||||
client.publish(mqtt_topic, mqtt_message);
|
client.publish(mqtt_topic, mqtt_message);
|
||||||
M.post('statuses', { status: `${mastodon_toot}` });
|
M.post('statuses', {
|
||||||
|
status: `${mastodon_toot}`
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
xmpp.on('chat', function(from, message) {
|
xmpp.on('chat', function(from, message) {
|
||||||
|
@ -163,7 +165,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
debug();
|
debug();
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
// Tuya light control
|
// Tuya light control
|
||||||
else if (message === '!lights') {
|
else if (message === '!lights') {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
|
@ -202,8 +205,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
debug();
|
debug();
|
||||||
}}
|
}
|
||||||
else if (message === tuya_name + ' on') {
|
} else if (message === tuya_name + ' on') {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -231,8 +234,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
debug();
|
debug();
|
||||||
}}
|
}
|
||||||
else if (message === tuya_name + ' off') {
|
} else if (message === tuya_name + ' off') {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -260,8 +263,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
debug();
|
debug();
|
||||||
}}
|
}
|
||||||
else if (message.includes(tuya_name + ' brightness')) {
|
} else if (message.includes(tuya_name + ' brightness')) {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -290,9 +293,10 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (config.debug === '1') {
|
if (config.debug === '1') {
|
||||||
console.log('lights turned to ' + per + "%");}
|
console.log('lights turned to ' + per + "%");
|
||||||
}}
|
}
|
||||||
else if (message.includes(tuya_name + ' color')) {
|
}
|
||||||
|
} else if (message.includes(tuya_name + ' color')) {
|
||||||
if (from != user_jid) {
|
if (from != user_jid) {
|
||||||
xmpp.send(from, pc);
|
xmpp.send(from, pc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -327,8 +331,10 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (config.debug === '1') {
|
if (config.debug === '1') {
|
||||||
console.log(tuya_name + "set to " + color);}
|
console.log(tuya_name + "set to " + color);
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Ping a user to let them know you would like to communicate
|
// Ping a user to let them know you would like to communicate
|
||||||
else if (message === '!ping') {
|
else if (message === '!ping') {
|
||||||
xmpp.send(from, "Pinging " + user_name + "! Please stand by.");
|
xmpp.send(from, "Pinging " + user_name + "! Please stand by.");
|
||||||
|
@ -384,7 +390,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
debug();
|
debug();
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sends a nice goodbye message
|
// Sends a nice goodbye message
|
||||||
else if (message === '!bye') {
|
else if (message === '!bye') {
|
||||||
|
@ -473,10 +480,12 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
if (error) throw new Error(error);
|
if (error) throw new Error(error);
|
||||||
console.log(body);
|
console.log(body);
|
||||||
});
|
});
|
||||||
}}, 2000);
|
}
|
||||||
|
}, 2000);
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
debug();
|
debug();
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// End meeting
|
// End meeting
|
||||||
else if (message === '!endmeet') {
|
else if (message === '!endmeet') {
|
||||||
|
@ -490,7 +499,10 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: xmpp_auth
|
Authorization: xmpp_auth
|
||||||
},
|
},
|
||||||
body: {name: xmpp_muc_name, service: xmpp_muc_server},
|
body: {
|
||||||
|
name: xmpp_muc_name,
|
||||||
|
service: xmpp_muc_server
|
||||||
|
},
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
request(endMeeting, function(error, response, body) {
|
request(endMeeting, function(error, response, body) {
|
||||||
|
@ -501,7 +513,9 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
for (const key in config.friends) {
|
for (const key in config.friends) {
|
||||||
xmpp.send(key, "Meeting ended");
|
xmpp.send(key, "Meeting ended");
|
||||||
}
|
}
|
||||||
}debug();}
|
}
|
||||||
|
debug();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,7 +527,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
xmpp.send(from, "Alrighty, shutting down. Goodbye!");
|
xmpp.send(from, "Alrighty, shutting down. Goodbye!");
|
||||||
debug();
|
debug();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get users vCard (WIP)
|
// Get users vCard (WIP)
|
||||||
else if (message === '!vcard') {
|
else if (message === '!vcard') {
|
||||||
|
@ -524,7 +539,8 @@ let gotifyEUrl = encodeURI(gotifyURL);
|
||||||
xmpp.send(from, vcard);
|
xmpp.send(from, vcard);
|
||||||
console.log(vcard)
|
console.log(vcard)
|
||||||
})
|
})
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the user sends something we don't have logic for, send them info about the project
|
// If the user sends something we don't have logic for, send them info about the project
|
||||||
else {
|
else {
|
||||||
|
|
Reference in New Issue
Block a user