Add Android/Desktop option to releasenotes command

This commit is contained in:
felhe 2019-10-06 13:07:36 +02:00
parent e692f7e824
commit 3ed0272558

View file

@ -9,16 +9,22 @@ exports.commands = [
]; ];
exports.releasenotes = { exports.releasenotes = {
usage: '', usage: '<desktop/android>',
description: 'gets current release notes from GITHUB', description: 'gets current release notes from GitHub, for either Desktop or Android',
process: function(bot, msg, suffix) { process: function(bot, msg, suffix) {
let releaseType = suffix.toLowerCase();
let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1);
if (releaseType !== 'android' && releaseType !== 'desktop') {
msg.reply('Please specify which release notes to display: "desktop" or "android".');
return;
}
const headers = { const headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'User-Agent': 'Super Agent/0.0.1' 'User-Agent': 'Super Agent/0.0.1'
}; };
// Configure the request // Configure the request
const options = { const options = {
url: 'https://api.github.com/repos/lbryio/lbry-desktop/releases/latest', url: 'https://api.github.com/repos/lbryio/lbry-' + releaseType + '/releases/latest',
method: 'GET', method: 'GET',
headers: headers headers: headers
}; };
@ -39,12 +45,12 @@ exports.releasenotes = {
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
name: 'LBRY Desktop release Notes for ' + releasename, name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename,
icon_url: 'https://spee.ch/b/Github-PNG-Image.png' icon_url: 'https://spee.ch/b/Github-PNG-Image.png'
}, },
footer: { footer: {
icon_url: 'https://spee.ch/2/pinkylbryheart.png', icon_url: 'https://spee.ch/2/pinkylbryheart.png',
text: 'LBRY Desktop Updated ' text: 'LBRY ' + releaseTypeName + ' updated '
} }
} }
}; };
@ -78,12 +84,12 @@ exports.releasenotes = {
color: 7976557, color: 7976557,
timestamp: releasedate, timestamp: releasedate,
author: { author: {
name: 'LBRY Desktop Release Notes for ' + releasename, name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename,
icon_url: 'https://spee.ch/b/Github-PNG-Image.png' icon_url: 'https://spee.ch/b/Github-PNG-Image.png'
}, },
footer: { footer: {
icon_url: 'https://spee.ch/2/pinkylbryheart.png', icon_url: 'https://spee.ch/2/pinkylbryheart.png',
text: 'LBRY Desktop Updated ' text: 'LBRY ' + releaseTypeName + ' updated '
} }
} }
}; };
@ -97,7 +103,7 @@ exports.releasenotes = {
}, },
footer: { footer: {
icon_url: 'https://spee.ch/2/pinkylbryheart.png', icon_url: 'https://spee.ch/2/pinkylbryheart.png',
text: 'LBRY Desktop Updated ' text: 'LBRY ' + releaseTypeName + ' updated '
} }
} }
}; };
@ -111,7 +117,7 @@ exports.releasenotes = {
}, },
footer: { footer: {
icon_url: 'https://spee.ch/2/pinkylbryheart.png', icon_url: 'https://spee.ch/2/pinkylbryheart.png',
text: 'LBRY Desktop Updated ' text: 'LBRY ' + releaseTypeName + ' updated '
} }
} }
}; };
@ -125,7 +131,7 @@ exports.releasenotes = {
}, },
footer: { footer: {
icon_url: 'https://spee.ch/2/pinkylbryheart.png', icon_url: 'https://spee.ch/2/pinkylbryheart.png',
text: 'LBRY Desktop Updated ' text: 'LBRY ' + releaseTypeName + ' updated '
} }
} }
}; };
@ -139,7 +145,7 @@ exports.releasenotes = {
}, },
footer: { footer: {
icon_url: 'https://spee.ch/2/pinkylbryheart.png', icon_url: 'https://spee.ch/2/pinkylbryheart.png',
text: 'LBRY Desktop Updated ' text: 'LBRY ' + releaseTypeName + ' updated '
} }
} }
}; };