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