forked from vxmppb/vxmppb
Adding mastodon user, commented out posting toot.
This commit is contained in:
parent
4bf12d42ab
commit
d61d768215
58
index.js
58
index.js
|
@ -44,6 +44,7 @@ try {
|
|||
const mastodon_api_url = config.mastodon.api_url;
|
||||
const mastodon_token = config.mastodon.token;
|
||||
const mastodon_toot = config.mastodon.toot;
|
||||
const mastodon_user = config.mastodon.user;
|
||||
|
||||
// MQTT config
|
||||
const mqtt_message = config.mqtt.message;
|
||||
|
@ -116,9 +117,12 @@ try {
|
|||
// send mqtt online message
|
||||
client.publish(mqtt_topic, mqtt_message);
|
||||
// toot online message
|
||||
/*
|
||||
M.post('statuses', {
|
||||
status: `${mastodon_toot}`
|
||||
});
|
||||
*/
|
||||
|
||||
});
|
||||
// wait for incoming messages
|
||||
xmpp.on('chat', function(from, message) {
|
||||
|
@ -184,6 +188,53 @@ try {
|
|||
debug();
|
||||
}
|
||||
}
|
||||
// Toot Unlocks
|
||||
else if (message === '!tootunlocks') {
|
||||
if (from != user_jid) {
|
||||
xmpp.send(from, pc);
|
||||
} else {
|
||||
var d = new Date();
|
||||
var weekday = new Array(7);
|
||||
weekday[0] = "Sunday";
|
||||
weekday[1] = "Monday";
|
||||
weekday[2] = "Tuesday";
|
||||
weekday[3] = "Wednesday";
|
||||
weekday[4] = "Thursday";
|
||||
weekday[5] = "Friday";
|
||||
weekday[6] = "Saturday";
|
||||
var n = weekday[d.getDay()];
|
||||
// get latest unlocks
|
||||
request(unlocks_api_url + "?columns=" + n, (error, res, body) => {
|
||||
if (error) {
|
||||
return console.log(error)
|
||||
};
|
||||
|
||||
if (!error && res.statusCode == 200) {
|
||||
var unlockBody = new RegExp(':(.*)}');
|
||||
var unlockBodyMatch = body.match(unlockBody);
|
||||
const unlockFinalMessage = "@" + config.mastodon.user + " has " + unlockBodyMatch[1] + " unlocks for " + n;
|
||||
M.post('statuses', {
|
||||
status: unlockFinalMessage
|
||||
});
|
||||
debug();
|
||||
}
|
||||
if (!error && res.statusCode == 401) {
|
||||
console.log('Invalid credentials');
|
||||
xmpp.send(from, 'Invalid credentials');
|
||||
}
|
||||
if (!error && res.statusCode == 404) {
|
||||
console.log('Record not found');
|
||||
xmpp.send(from, 'Record not found');
|
||||
}
|
||||
if (!error && res.statusCode == 500) {
|
||||
console.log('Server error.');
|
||||
xmpp.send(from, 'Server error. Please ping admin');
|
||||
}
|
||||
});
|
||||
debug();
|
||||
}
|
||||
}
|
||||
|
||||
// Tuya light control
|
||||
else if (message === '!lights') {
|
||||
if (from != user_jid) {
|
||||
|
@ -219,7 +270,7 @@ try {
|
|||
}
|
||||
if (!error && res.statusCode == 500) {
|
||||
console.log('Server error.');
|
||||
xmpp.send(from, 'Server error. Please ping admin');
|
||||
xmpp.send(from, 'Server error. Please !ping');
|
||||
}
|
||||
});
|
||||
debug();
|
||||
|
@ -430,9 +481,12 @@ try {
|
|||
}
|
||||
|
||||
|
||||
// Share-A-Command which was #13, but kinda turned into a different command
|
||||
// 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
|
||||
// Please not this section requires you to have an Ejabberd server.
|
||||
// I am welcome to pull requests for other servers (maybe set type in config.ini)
|
||||
|
||||
else if (message === '!meet') {
|
||||
if (from != user_jid) {
|
||||
xmpp.send(from, pc);
|
||||
|
|
Reference in New Issue
Block a user