From d90571adf09bab4f0c2791a23b46568d1cab77e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2019 14:09:14 +0000 Subject: [PATCH 01/48] Bump mixin-deep from 1.3.1 to 1.3.2 Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases) - [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e20a86..8bb1dbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2599,9 +2599,9 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "optional": true, "requires": { "for-in": "^1.0.2", From 20380614cd8235de3f3dd994d185317748a6f2c9 Mon Sep 17 00:00:00 2001 From: Electron - Mark Firth Date: Thu, 5 Sep 2019 22:57:11 +1000 Subject: [PATCH 02/48] Improvements 1) Removed `!rewardsapprove` and `!verification` as they are duplicates of `!rewardsapproval` 2) Added a `!whitepaper` command that links to the LBRY White Paper. 3) Added some new and improved icons to some cards. 4) Changed the left border colour of some cards to match their new icons. --- config/commands.json | 56 ++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/config/commands.json b/config/commands.json index 531e15e..2fc9108 100644 --- a/config/commands.json +++ b/config/commands.json @@ -30,6 +30,22 @@ "icon_url": "https://spee.ch/2/pinkylbryheart.png" } } + }, + "!whitepaper": { + "usage": "", + "description": "LBRY White Paper", + "operation": "send", + "bundle": { + "url": "https://spec.lbry.com/", + "title": "", + "description": "The [LBRY White Paper](https://spec.lbry.com/) defines the LBRY protocol, its components, and how they fit together. \nThis document assumes that the reader is familiar with distributed hash tables (DHTs), the BitTorrent protocol, Bitcoin, and blockchain technology in general. It does not attempt to document these technologies or explain how they work.", + "color": 16777215, + "author": { + "name": "LBRY White Paper", + "url": "https://spec.lbry.com/", + "icon_url": "https://spee.ch/0/info-white.png" + } + } }, "!begging": { "usage": "", @@ -39,11 +55,11 @@ "url": "", "title": "", "description": "Please don't request free coins or invites, we have a strict policy against begging. Further offenses will result in removal from the chat.", - "color": 7976557, + "color": 16718635, "author": { "name": "BEGGING!", "url": "", - "icon_url": "https://spee.ch/7/LBRY-Discord-Warning.png" + "icon_url": "https://spee.ch/8/caution-red.png" } } }, @@ -263,11 +279,11 @@ "url": "", "title": "", "description": "Please keep conversations on topic, or move random conversations to #random if you wish to continue", - "color": 7976557, + "color": 16764237, "author": { "name": "Random", "url": "", - "icon_url": "https://spee.ch/7/LBRY-Discord-Warning.png" + "icon_url": "https://spee.ch/3/question-orange.png" } } }, @@ -383,22 +399,6 @@ } } }, - "!rewardsapprove": { - "usage": "", - "description": "How to become Rewards approved", - "operation": "send", - "bundle": { - "url": "", - "title": "", - "description": "Please download the latest version from [HERE](https://lbry.com/get) Upon install, you'll be greeted with a welcome message. If you already had the app installed, please go to the wallet (bank icon in the top right) > Rewards - This should show your current status. New users will need to get their rewards approved in order to access Rewards. Type !cc or see the !rewardsapproval information below.", - "color": 7976557, - "author": { - "name": "How to become Rewards approved", - "url": "", - "icon_url": "https://spee.ch/2/pinkylbryheart.png" - } - } - }, "!verify": { "usage": "", "description": "How to become Rewards approved", @@ -431,22 +431,6 @@ } } }, - "!verification": { - "usage": "", - "description": "Rewards Approval Help Message", - "operation": "send", - "bundle": { - "url": "", - "title": "", - "description": "If you would like to be approved for rewards, please go to <#571001864271691805> and send a Direct Message to @RewardsBot#0287 \n You can do this by right clicking on the name, and selecting Message. . A LBRY mod will get back to you as soon as possible. We appreciate your patience. Only one account per household is allowed access to LBRY Rewards. Check out our [Rewards FAQ](https://lbry.io/faq/rewards) to know more about rewards.", - "color": 7976557, - "author": { - "name": "Applying for Rewards Approval", - "url": "", - "icon_url": "https://spee.ch/2/pinkylbryheart.png" - } - } - }, "!logfile": { "usage": "", "description": "How to Find LBRY App Log File?", From a84b4b34c1232eaa20db5bce795d71f0e5495f53 Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 30 Sep 2019 00:44:33 -0400 Subject: [PATCH 03/48] Update mongodb version --- package-lock.json | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8bb1dbe..92b6e03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2633,23 +2633,13 @@ "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" }, "mongodb": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.7.tgz", - "integrity": "sha512-2YdWrdf1PJgxcCrT1tWoL6nHuk6hCxhddAAaEh8QJL231ci4+P9FLyqopbTm2Z2sAU6mhCri+wd9r1hOcHdoMw==", - "requires": { - "mongodb-core": "3.2.7", - "safe-buffer": "^5.1.2" - } - }, - "mongodb-core": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.7.tgz", - "integrity": "sha512-WypKdLxFNPOH/Jy6i9z47IjG2wIldA54iDZBmHMINcgKOUcWJh8og+Wix76oGd7EyYkHJKssQ2FAOw5Su/n4XQ==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.3.2.tgz", + "integrity": "sha512-fqJt3iywelk4yKu/lfwQg163Bjpo5zDKhXiohycvon4iQHbrfflSAz9AIlRE6496Pm/dQKQK5bMigdVo2s6gBg==", "requires": { "bson": "^1.1.1", "require_optional": "^1.0.1", "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" } }, "mongoose": { From e692f7e8242d770385e7df2b6f52192b7e771079 Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 30 Sep 2019 00:54:53 -0400 Subject: [PATCH 04/48] Corrected syntax --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 92b6e03..92a232f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2639,7 +2639,7 @@ "requires": { "bson": "^1.1.1", "require_optional": "^1.0.1", - "safe-buffer": "^5.1.2", + "safe-buffer": "^5.1.2" } }, "mongoose": { From 3ed02725584acaafc8e87f5dd712db994eca3737 Mon Sep 17 00:00:00 2001 From: felhe <10731299+felhe@users.noreply.github.com> Date: Sun, 6 Oct 2019 13:07:36 +0200 Subject: [PATCH 05/48] Add Android/Desktop option to releasenotes command --- bot/modules/releasenotes.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index b2d7650..266fe3b 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -9,16 +9,22 @@ exports.commands = [ ]; exports.releasenotes = { - usage: '', - description: 'gets current release notes from GITHUB', + usage: '', + description: 'gets current release notes from GitHub, for either Desktop or Android', 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 = { 'Content-Type': 'application/json', 'User-Agent': 'Super Agent/0.0.1' }; // Configure the request 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', headers: headers }; @@ -39,12 +45,12 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, 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' }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY Desktop Updated ' + text: 'LBRY ' + releaseTypeName + ' updated ' } } }; @@ -78,12 +84,12 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, 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' }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY Desktop Updated ' + text: 'LBRY ' + releaseTypeName + ' updated ' } } }; @@ -97,7 +103,7 @@ exports.releasenotes = { }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY Desktop Updated ' + text: 'LBRY ' + releaseTypeName + ' updated ' } } }; @@ -111,7 +117,7 @@ exports.releasenotes = { }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY Desktop Updated ' + text: 'LBRY ' + releaseTypeName + ' updated ' } } }; @@ -125,7 +131,7 @@ exports.releasenotes = { }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY Desktop Updated ' + text: 'LBRY ' + releaseTypeName + ' updated ' } } }; @@ -139,7 +145,7 @@ exports.releasenotes = { }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY Desktop Updated ' + text: 'LBRY ' + releaseTypeName + ' updated ' } } }; From d722a943d1a39fbe26cd6c276759590f64933532 Mon Sep 17 00:00:00 2001 From: felhe <10731299+felhe@users.noreply.github.com> Date: Sun, 6 Oct 2019 14:04:13 +0200 Subject: [PATCH 06/48] Refactor releasenotes and improve layout --- bot/modules/releasenotes.js | 134 ++++++++++-------------------------- 1 file changed, 36 insertions(+), 98 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 266fe3b..2fafa08 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -28,19 +28,19 @@ exports.releasenotes = { method: 'GET', headers: headers }; - // Start the request let message; request(options, function(error, response, body) { - let releasemessage = JSON.parse(body).body; - let releasename = JSON.parse(body).name; - let releasedate = JSON.parse(body).published_at; - let releaseurl = JSON.parse(body).html_url; + let json = JSON.parse(body); + let releasemessage = json.body; + let releasename = json.name || json.tag_name; + let releasedate = json.published_at; + let releaseurl = json.html_url; if (releasemessage.length < 2000) { message = { embed: { title: '*Download ' + releasename + ' here!*', - description: releasemessage, + description: releasemessage.replace('###', ''), url: releaseurl, color: 7976557, timestamp: releasedate, @@ -71,105 +71,43 @@ exports.releasenotes = { .filter(function(n) { return n !== ''; }); - let releasemessage1 = message[0]; - let releasemessage2 = message[1]; - let releasemessage3 = message[2]; - let releasemessage4 = message[3]; - let releasemessage5 = message[4]; - let message1 = { - embed: { - title: '*Download ' + releasename + ' here!*', - description: releasemessage1, - url: releaseurl, - color: 7976557, - timestamp: releasedate, - author: { - name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, - icon_url: 'https://spee.ch/b/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' - } + let embedmessages = []; + for (let i = 0; i < message.length; i++) { + if (message[i]) { + embedmessages.push({ + embed: { + description: message[i], + url: releaseurl, + color: 7976557, + timestamp: releasedate, + author: { + name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, + icon_url: 'https://spee.ch/b/Github-PNG-Image.png' + }, + footer: { + icon_url: 'https://spee.ch/2/pinkylbryheart.png', + text: 'LBRY ' + releaseTypeName + ' updated ' + } + } + }); + if (i === 0) embedmessages[i].embed.title = '*Download ' + releasename + ' here!*'; } - }; - let message2 = { - embed: { - description: releasemessage2, - color: 7976557, - timestamp: releasedate, - author: { - icon_url: 'https://spee.ch/b/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' - } - } - }; - let message3 = { - embed: { - description: releasemessage3, - color: 7976557, - timestamp: releasedate, - author: { - icon_url: 'https://spee.ch/b/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' - } - } - }; - let message4 = { - embed: { - description: releasemessage4, - color: 7976557, - timestamp: releasedate, - author: { - icon_url: 'https://spee.ch/b/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' - } - } - }; - let message5 = { - embed: { - description: releasemessage5, - color: 7976557, - timestamp: releasedate, - author: { - icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' - } - } - }; + } if (inPrivate(msg)) { - msg.channel.send(message1); - msg.channel.send(message2); - msg.channel.send(message3); - msg.channel.send(message4); - msg.channel.send(message5); + for (let i = 0; i < embedmessages.length; i++) { + msg.channel.send(embedmessages[i]); + } return; } if (hasPerms(msg) && suffix === 'post') { - bot.channels.get(ChannelID).send(message1); - bot.channels.get(ChannelID).send(message2); - bot.channels.get(ChannelID).send(message3); - bot.channels.get(ChannelID).send(message4); - bot.channels.get(ChannelID).send(message5); + for (let i = 0; i < embedmessages.length; i++) { + bot.channels.get(ChannelID).send(embedmessages[i]); + } } else { msg.channel.send(msg.author + ' Release notes sent via DM'); - msg.author.send(message1); - msg.author.send(message2); - msg.author.send(message3); - msg.author.send(message4); - msg.author.send(message5); + for (let i = 0; i < embedmessages.length; i++) { + msg.author.send(embedmessages[i]); + } } } }); From 6413cffebbddfc986ae49296d1c371675ea88f92 Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 7 Oct 2019 01:31:34 -0400 Subject: [PATCH 07/48] Remove Community Roles --- config/default.example.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.example.json b/config/default.example.json index fb2515b..dd89353 100644 --- a/config/default.example.json +++ b/config/default.example.json @@ -63,7 +63,7 @@ }, "rolelist": { "baserole": "LBRYian", - "allowedroles": ["NSFW", "Traders", "Miners", "Off-Topic Chats", "International", "Dev"] + "allowedroles": ["Off-Topic Chats", "Dev"] }, "irc": { "nickname": "wunderbot", From 9a9607e755b743c47432efa895d18bf814eacc8e Mon Sep 17 00:00:00 2001 From: ICTman1076 Date: Mon, 7 Oct 2019 18:38:22 +0100 Subject: [PATCH 08/48] Proposed !why command Thought I may as well write something for #245 --- config/commands.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config/commands.json b/config/commands.json index 2fc9108..7426fdb 100644 --- a/config/commands.json +++ b/config/commands.json @@ -898,6 +898,22 @@ } }, + "!why": { + "usage": "", + "description": "Why should I use LBRY?", + "operation": "send", + "bundle": { + "url": "", + "title": "", + "description": "LBRY is a new protocol which allows anyone to build apps that interact with digital content on the LBRY network. Apps built on the protocol allow creators to upload their work to the LBRY network of hosts (like BitTorrent), and set a price per stream or download (like iTunes) or give it away for free (like YouTube without ads). It benefits the consumer, because there's no ads, and you can often buy things cheaper on LBRY, and it benefits the creator, because there's no risk of demonetization, essentially no fees, and it's a lot harder to censor. You can find out more on the [FAQ](https://lbry.com/faq), or ask anyone here for their experience!", + "color": 7976557, + "author": { + "name": "Why should I use LBRY?", + "url": "https://lbry.com/faq", + "icon_url": "https://spee.ch/2/pinkylbryheart.png" + } + } + "!piratebay": { "usage": "", "description": "Why LBRY has piratebay.com", From 1411fb28c929acd3d43a02edab4048802b1210f6 Mon Sep 17 00:00:00 2001 From: Haichuan He Date: Mon, 7 Oct 2019 16:28:18 -0400 Subject: [PATCH 09/48] replace var with let for purge.js --- bot/modules/purge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/purge.js b/bot/modules/purge.js index e43cd56..66406a8 100644 --- a/bot/modules/purge.js +++ b/bot/modules/purge.js @@ -16,8 +16,8 @@ exports.purge = { if (!suffix) { var newamount = '2'; } else { - var amount = Number(suffix); - var adding = 1; + let amount = Number(suffix); + let adding = 1; var newamount = amount + adding; } let messagecount = newamount.toString(); From 13385b38df69c50123d659fabc47774cb3af0573 Mon Sep 17 00:00:00 2001 From: Haichuan He Date: Mon, 7 Oct 2019 17:07:43 -0400 Subject: [PATCH 10/48] replace var with let for price.js and purge.js --- bot/modules/price.js | 44 ++++++++++++++++++++++---------------------- bot/modules/purge.js | 5 +++-- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/bot/modules/price.js b/bot/modules/price.js index 5928a7e..d59e904 100644 --- a/bot/modules/price.js +++ b/bot/modules/price.js @@ -14,7 +14,7 @@ exports.price = { usage: ' ', description: 'displays price of lbc', process: function(bot, msg, suffix) { - var options = { + let options = { defaultCurrency: 'BTC', // supported currencies and api steps to arrive at the final value @@ -503,22 +503,22 @@ exports.price = { // refresh rate in milliseconds to retrieve a new price (default to 10 minutes) refreshTime: 100000 }; - var words = suffix + let words = suffix .trim() .split(' ') .filter(function(n) { return n !== ''; }); - var currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency; - var amount = words.length > 1 ? parseFloat(words[1], 10) : 1; - var showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1; + let currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency; + let amount = words.length > 1 ? parseFloat(words[1], 10) : 1; + let showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1; // store the last retrieved rate - var cachedRates = {}; - var command = '!price'; + let cachedRates = {}; + let command = '!price'; - var currencies = Object.keys(options.currencies); - for (var i = 0; i < currencies.length; i++) { + let currencies = Object.keys(options.currencies); + for (let i = 0; i < currencies.length; i++) { cachedRates[currencies[i]] = { rate: 0, time: null @@ -539,7 +539,7 @@ exports.price = { msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.'); return; } - var message = `**${command}**: show the price of 1 LBC in ${options.defaultCurrency} + let message = `**${command}**: show the price of 1 LBC in ${options.defaultCurrency} **${command} help**: this message **${command} CURRENCY**: show the price of 1 LBC in CURRENCY. Supported values for CURRENCY are Listed Below **${command} CURRENCY AMOUNT**: show the price of AMOUNT LBC in CURRENCY @@ -548,28 +548,28 @@ exports.price = { } function formatMessage(amount, rate, option) { - var cur = option.sign; - var value = numeral(rate.rate * amount).format(option.format); + let cur = option.sign; + let value = numeral(rate.rate * amount).format(option.format); return `*${numeral(amount).format('0,0[.][00000000]')} LBC = ${cur} ${value}* _last updated ${rate.time.utc().format(options.dtFormat)}_`; } function doSteps(bot, currency, amount) { - var option = options.currencies[currency]; - var shouldReload = true; + let option = options.currencies[currency]; + let shouldReload = true; if (cachedRates[currency]) { - var cache = cachedRates[currency]; + let cache = cachedRates[currency]; shouldReload = cache.time === null || moment().diff(cache.time) >= options.refreshTime; if (!shouldReload) { - var message = formatMessage(amount, cache, option); + let message = formatMessage(amount, cache, option); msg.channel.send(message); } } if (shouldReload) { // copy the steps array - var steps = []; - for (var i = 0; i < option.steps.length; i++) { + let steps = []; + for (let i = 0; i < option.steps.length; i++) { steps.push(option.steps[i]); } @@ -579,19 +579,19 @@ _last updated ${rate.time.utc().format(options.dtFormat)}_`; function processSteps(bot, currency, rate, amount, steps, option) { if (steps.length > 0) { - var pairName = steps[0]; + let pairName = steps[0]; if (!options.api[pairName]) { msg.channel.send(`There was a configuration error. ${pairName} pair was not found.`); return; } - var pair = options.api[pairName]; + let pair = options.api[pairName]; request.get(pair.url, function(error, response, body) { if (error) { msg.channel.send(err.message ? err.message : 'The request could not be completed at this time. Please try again later.'); return; } - var pairRate = 0; + let pairRate = 0; try { pairRate = jp.query(JSON.parse(body), pair.path); if (Array.isArray(pairRate) && pairRate.length > 0) { @@ -610,7 +610,7 @@ _last updated ${rate.time.utc().format(options.dtFormat)}_`; } // final step, cache and then response - var result = { + let result = { rate: rate, time: moment() }; diff --git a/bot/modules/purge.js b/bot/modules/purge.js index 66406a8..36cf54e 100644 --- a/bot/modules/purge.js +++ b/bot/modules/purge.js @@ -13,12 +13,13 @@ exports.purge = { return; } if (hasPerms(msg)) { + let newamount = 0 if (!suffix) { - var newamount = '2'; + newamount = 2; } else { let amount = Number(suffix); let adding = 1; - var newamount = amount + adding; + newamount = amount + adding; } let messagecount = newamount.toString(); msg.channel From fe0ee6229abe64745d78abaea3a1d8ed58723183 Mon Sep 17 00:00:00 2001 From: Haichuan He Date: Mon, 7 Oct 2019 17:07:43 -0400 Subject: [PATCH 11/48] Fix#261: remove vars --- bot/modules/price.js | 44 ++++++++++++++++++++++---------------------- bot/modules/purge.js | 5 +++-- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/bot/modules/price.js b/bot/modules/price.js index 5928a7e..d59e904 100644 --- a/bot/modules/price.js +++ b/bot/modules/price.js @@ -14,7 +14,7 @@ exports.price = { usage: ' ', description: 'displays price of lbc', process: function(bot, msg, suffix) { - var options = { + let options = { defaultCurrency: 'BTC', // supported currencies and api steps to arrive at the final value @@ -503,22 +503,22 @@ exports.price = { // refresh rate in milliseconds to retrieve a new price (default to 10 minutes) refreshTime: 100000 }; - var words = suffix + let words = suffix .trim() .split(' ') .filter(function(n) { return n !== ''; }); - var currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency; - var amount = words.length > 1 ? parseFloat(words[1], 10) : 1; - var showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1; + let currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency; + let amount = words.length > 1 ? parseFloat(words[1], 10) : 1; + let showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1; // store the last retrieved rate - var cachedRates = {}; - var command = '!price'; + let cachedRates = {}; + let command = '!price'; - var currencies = Object.keys(options.currencies); - for (var i = 0; i < currencies.length; i++) { + let currencies = Object.keys(options.currencies); + for (let i = 0; i < currencies.length; i++) { cachedRates[currencies[i]] = { rate: 0, time: null @@ -539,7 +539,7 @@ exports.price = { msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.'); return; } - var message = `**${command}**: show the price of 1 LBC in ${options.defaultCurrency} + let message = `**${command}**: show the price of 1 LBC in ${options.defaultCurrency} **${command} help**: this message **${command} CURRENCY**: show the price of 1 LBC in CURRENCY. Supported values for CURRENCY are Listed Below **${command} CURRENCY AMOUNT**: show the price of AMOUNT LBC in CURRENCY @@ -548,28 +548,28 @@ exports.price = { } function formatMessage(amount, rate, option) { - var cur = option.sign; - var value = numeral(rate.rate * amount).format(option.format); + let cur = option.sign; + let value = numeral(rate.rate * amount).format(option.format); return `*${numeral(amount).format('0,0[.][00000000]')} LBC = ${cur} ${value}* _last updated ${rate.time.utc().format(options.dtFormat)}_`; } function doSteps(bot, currency, amount) { - var option = options.currencies[currency]; - var shouldReload = true; + let option = options.currencies[currency]; + let shouldReload = true; if (cachedRates[currency]) { - var cache = cachedRates[currency]; + let cache = cachedRates[currency]; shouldReload = cache.time === null || moment().diff(cache.time) >= options.refreshTime; if (!shouldReload) { - var message = formatMessage(amount, cache, option); + let message = formatMessage(amount, cache, option); msg.channel.send(message); } } if (shouldReload) { // copy the steps array - var steps = []; - for (var i = 0; i < option.steps.length; i++) { + let steps = []; + for (let i = 0; i < option.steps.length; i++) { steps.push(option.steps[i]); } @@ -579,19 +579,19 @@ _last updated ${rate.time.utc().format(options.dtFormat)}_`; function processSteps(bot, currency, rate, amount, steps, option) { if (steps.length > 0) { - var pairName = steps[0]; + let pairName = steps[0]; if (!options.api[pairName]) { msg.channel.send(`There was a configuration error. ${pairName} pair was not found.`); return; } - var pair = options.api[pairName]; + let pair = options.api[pairName]; request.get(pair.url, function(error, response, body) { if (error) { msg.channel.send(err.message ? err.message : 'The request could not be completed at this time. Please try again later.'); return; } - var pairRate = 0; + let pairRate = 0; try { pairRate = jp.query(JSON.parse(body), pair.path); if (Array.isArray(pairRate) && pairRate.length > 0) { @@ -610,7 +610,7 @@ _last updated ${rate.time.utc().format(options.dtFormat)}_`; } // final step, cache and then response - var result = { + let result = { rate: rate, time: moment() }; diff --git a/bot/modules/purge.js b/bot/modules/purge.js index 66406a8..36cf54e 100644 --- a/bot/modules/purge.js +++ b/bot/modules/purge.js @@ -13,12 +13,13 @@ exports.purge = { return; } if (hasPerms(msg)) { + let newamount = 0 if (!suffix) { - var newamount = '2'; + newamount = 2; } else { let amount = Number(suffix); let adding = 1; - var newamount = amount + adding; + newamount = amount + adding; } let messagecount = newamount.toString(); msg.channel From dc526adf1ad2d3127a4fec50763df29e1059e8ba Mon Sep 17 00:00:00 2001 From: Haichuan He Date: Mon, 7 Oct 2019 17:22:23 -0400 Subject: [PATCH 12/48] Fix#261:remove vars for purge.js --- bot/modules/purge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/purge.js b/bot/modules/purge.js index 36cf54e..32c64ec 100644 --- a/bot/modules/purge.js +++ b/bot/modules/purge.js @@ -13,7 +13,7 @@ exports.purge = { return; } if (hasPerms(msg)) { - let newamount = 0 + let newamount = 0; if (!suffix) { newamount = 2; } else { From 2fc9928ab97c5b8266503e91d2d83bd735f24652 Mon Sep 17 00:00:00 2001 From: utkarshiam Date: Tue, 8 Oct 2019 05:21:48 +0530 Subject: [PATCH 13/48] The Strict Equality Comparison added --- bot/bot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot/bot.js b/bot/bot.js index 392a822..7e34bce 100644 --- a/bot/bot.js +++ b/bot/bot.js @@ -71,9 +71,9 @@ bot.on('error', function(error) { function checkMessageForCommand(msg, isEdit) { //check if message is a command - if (msg.author.id != bot.user.id && msg.content.startsWith(config.prefix)) { + if (msg.author.id !== bot.user.id && msg.content.startsWith(config.prefix)) { //check if user is Online - if (!msg.author.presence.status || msg.author.presence.status == 'offline' || msg.author.presence.status == 'invisible') { + if (!msg.author.presence.status || msg.author.presence.status === 'offline' || msg.author.presence.status === 'invisible') { msg.author.send('Please set your Discord Presence to Online to talk to the bot!').catch(function(error) { msg.channel .send( @@ -183,7 +183,7 @@ function checkMessageForCommand(msg, isEdit) { return; } - if (msg.author != bot.user && msg.isMentioned(bot.user)) { + if (msg.author !== bot.user && msg.isMentioned(bot.user)) { msg.channel.send('yes?'); //using a mention here can lead to looping } else { } From 74d4dec0dcf8bc2739c33ab2457a350df46a161e Mon Sep 17 00:00:00 2001 From: ProfessorDey Date: Tue, 8 Oct 2019 22:54:01 +0100 Subject: [PATCH 14/48] Simplify rolesetter.js Control Logic Eliminates nesting of if-else statements and follows imperative control logic, making it much clearer what error messages are which and what order logic is handled in. Also neatens up the calls to 'msg.channel.send' into a single compact function declaration. Also eliminates case sensitivity entirely with a minimal performance hit by only performing '.toLowerCase()' on the first check for new/oldrole, though this could be replaced with a regexp object test instead. Every other comparison uses the matched role's name as this is guaranteed to be the correct case, assuming no issues with the config itself. This means users can enter the role in any case, preventing the biggest irritation to most users besides spelling errors. --- bot/modules/rolesetter.js | 128 ++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 66 deletions(-) diff --git a/bot/modules/rolesetter.js b/bot/modules/rolesetter.js index a7ba2b6..af7351e 100644 --- a/bot/modules/rolesetter.js +++ b/bot/modules/rolesetter.js @@ -13,47 +13,46 @@ exports.addrole = { usage: '', description: 'Adds you to specified role', process: function(bot, msg, suffix) { - //rolelist.allowedroles = rolelist.allowedroles.map(v => v.toLowerCase()); - // Here the bot,msg and suffix is avaible, this function can be async if needed. - let newrole = msg.guild.roles.find('name', suffix); + // Here the bot, msg and suffix is avaible, this function can be async if needed. + // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. + let newrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); + // Baserole is assumed to already be case accurate as it's handled in the config itself. let baserole = msg.guild.roles.find('name', rolelist.baserole); - // Checks if the user put a role in the message. - if (inPrivate(msg)) { - msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.'); + + // Provide shortened syntax for the sake of code cleanliness + let send = (msgTxt) => { msg.channel.send(msgTxt); return; }; + let rolecmd = botconfig.prefix + "roles"; + + // Checks if the user has messaged the bot via Direct Message + if (inPrivate(msg)) + return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + // Checks if the user included a role in their message + if (!suffix) + return send("Please specify a role. Type " + rolecmd + " to see which you may add yourself!"); + // Checks if there is a matching role found on the server + if(!newrole) + return send("The role specified `" + suffix + "` does not exist on this server!"); + // Checks that the allowed roles and base role against the matched role's name, since this eliminates case sensitivity issues + if(!rolelist.allowedroles.includes(newrole.name) && !rolelist.baserole.includes(newrole.name)) + return send("That role isn't one you can add yourself to! Type " + rolecmd + " command to find out which ones are allowed."); + // Use the matched name to check against the member's existing roles + if(msg.member.roles.find('name', newrole.name)) + return send("It seems you already have the " + newrole.name + "role"); + + // Assuming all these factors succeed, add the role + msg.member.addRole(newrole).then(send(msg.member + " has been added to the " + newrole.name + " role!")); + + // Check if a baserole is actually set + if(!rolelist.baserole) return; - } else { - if (suffix) { - //suffix = suffix.toLowerCase(); - // Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config. - if (rolelist.allowedroles.includes(suffix) || rolelist.baserole.includes(suffix)) { - // Checks if the role even exists in the discord server - if (newrole !== null) { - // Checks if the member has the role that they are trying to add - if (!msg.member.roles.find('name', suffix)) { - msg.member.addRole(newrole).then(msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!')); - if (rolelist.baserole !== ' ') { - if (baserole !== null) { - // Checks if Member has the baserole, and also checks if they just added the baserole - if (!msg.member.roles.find('name', rolelist.baserole) && suffix !== rolelist.baserole) { - msg.member.addRole(baserole).then(msg.channel.send(msg.member + ' has been added to the ' + rolelist.baserole + ' role!')); - } - } else { - msg.channel.send('The ' + rolelist.baserole + " Role doesn't exist. Please add that role first!"); - } - } - } else { - msg.channel.send('It seems that you already have that role! Try removing it first with the ' + botconfig.prefix + 'delrole command!'); - } - } else { - msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!'); - } - } else { - msg.channel.send("That role isn't one you can add yourself to! Please run the " + botconfig.prefix + 'roles command to find out which ones are allowed.'); - } - } else { - msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!'); - } - } + // Confirm that the role exists on the server and if not then be sure to send a nag message + if(!baserole) + return send("The base role of " + rolelist.baserole + " has been set in config but is missing from the server"); + // Confirm if the user has the baserole already, including if it was added just now + if(msg.member.roles.find('name', baserole.name)) + return; + // Add the base role and avoid spamming the user by only mentioning them in the previous message + msg.member.addRole(baserole).then(send("We also added the base " + rolelist.baserole + " role for you!")); } }; exports.delrole = { @@ -61,33 +60,30 @@ exports.delrole = { description: 'Deletes the specified role from your account', process: function(bot, msg, suffix) { // Here in the bot, msg and suffix are available, this function can be async if needed. - let oldrole = msg.guild.roles.find('name', suffix); - // Checks if the user put a role in the message. - if (inPrivate(msg)) { - msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.'); - return; - } else { - if (suffix) { - // Checks if the role mentioned in the message is in the allowed roles listed in the Wunderbot config. - if (rolelist.allowedroles.includes(suffix)) { - // Checks if the role exists in the Discord server - if (oldrole !== null) { - // Checks if the member has the role that they are trying to add - if (msg.member.roles.find('name', suffix)) { - msg.member.removeRole(oldrole).then(msg.channel.send(msg.member + ' has been removed from the ' + suffix + ' role!')); - } else { - msg.channel.send("You don't seem to have that role! Try adding it first with the " + botconfig.prefix + 'addrole command!'); - } - } else { - msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!'); - } - } else { - msg.channel.send("That role isn't one you can add yourself to! Please run the " + botconfig.prefix + 'roles command to find out which ones are allowed.'); - } - } else { - msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!'); - } - } + // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. + let oldrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); + // Provide shortened syntax for the sake of code cleanliness + let send = (msgTxt) => { msg.channel.send(msgTxt); return; }; + let rolecmd = botconfig.prefix + "roles"; + + // Checks if the user has messaged the bot via Direct Message + if (inPrivate(msg)) + return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + // Checks if the user included a role in their message + if (!suffix) + return send("Please specify a role. Type " + rolecmd + " to see which you may remove yourself!"); + // Checks if there is a matching role found on the server + if(!newrole) + return send("The role specified `" + suffix + "` does not exist on this server!"); + // Checks that the allowed roles against the matched role's name, since this eliminates case sensitivity issues + if(!rolelist.allowedroles.includes(oldrole.name)) + return send("That role isn't one you can remove yourself! If you need it removed, please ask a moderator!"); + // Use the matched name to check against the member's existing roles + if(!msg.member.roles.find('name', oldrole.name)) + return send("It seems you don't actually have the " + oldrole.name + "role! Mission accomplished!"); + + // Assuming all these factors succeed, add the role + msg.member.removeRole(oldrole).then(send(msg.member + " has been removed from the " + oldrole.name + " role!")); } }; exports.roles = { From 516d0737cab6404c3bd44e1929b627edf83f8149 Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Wed, 9 Oct 2019 22:42:32 +0700 Subject: [PATCH 15/48] change api from coinmarketcap to coingecko --- bot/modules/stats.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 8dd774e..e3af7ff 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -8,20 +8,20 @@ exports.stats = { usage: '', description: 'Displays list of current Market stats', process: function(bot, msg) { - needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=BTC', function(error, response) { + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d +', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coinmarketcap API is not available'); } else { let data = response.body.data; - let rank = data.rank; - let price_usd = Number(data.quotes.USD.price); - let price_btc = Number(data.quotes.BTC.price); + let rank = data.market_cap_rank; + let price_btc = Number(data.current_price); let market_cap_usd = Number(data.quotes.USD.market_cap); let circulating_supply = Number(data.circulating_supply); let total_supply = Number(data.total_supply); - let percent_change_1h = Number(data.quotes.USD.percent_change_1h); - let percent_change_24h = Number(data.quotes.USD.percent_change_24h); - let volume24_usd = Number(data.quotes.USD.volume_24h); + let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); + let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); + let volume24_btc = Number(data.total_volume); let dt = new Date(); let timestamp = dt.toUTCString(); let hr_indicator = ':thumbsup:'; @@ -33,18 +33,24 @@ exports.stats = { day_indicator = ':thumbsdown:'; } - needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=GBP', function(error, response) { + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=gbp&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coinmarketcap API is not available'); } else { data = response.body.data; - let price_gbp = Number(data.quotes.GBP.price); - needle.get('https://api.coinmarketcap.com/v2/ticker/1298/?convert=EUR', function(error, response) { + let price_gbp = Number(data.current_price); + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coinmarketcap API is not available'); } else { data = response.body.data; - let price_eur = Number(data.quotes.EUR.price); + let price_eur = Number(data.current_price); + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { + if (error || response.statusCode !== 200) { + msg.channel.send('coinmarketcap API is not available'); + } else { + data = response.body.data; + let price_usd = Number(data.current_price); let description = `**Rank: [${rank}](${statsurl})** **Data** Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) From 4802cebf63568671d536dc669cf20ab841774241 Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Wed, 9 Oct 2019 23:39:37 +0700 Subject: [PATCH 16/48] Update stats.js --- bot/modules/stats.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index e3af7ff..20d2c7d 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -11,12 +11,12 @@ exports.stats = { needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d ', function(error, response) { if (error || response.statusCode !== 200) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { let data = response.body.data; let rank = data.market_cap_rank; let price_btc = Number(data.current_price); - let market_cap_usd = Number(data.quotes.USD.market_cap); + let market_cap_btc = Number(data.quotes.market_cap); let circulating_supply = Number(data.circulating_supply); let total_supply = Number(data.total_supply); let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); @@ -35,19 +35,19 @@ exports.stats = { needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=gbp&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { if (error || response.statusCode !== 200) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { data = response.body.data; let price_gbp = Number(data.current_price); needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { if (error || response.statusCode !== 200) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { data = response.body.data; - let price_eur = Number(data.current_price); + let price_eur\ = Number(data.current_price); needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { if (error || response.statusCode !== 200) { - msg.channel.send('coinmarketcap API is not available'); + msg.channel.send('coingecko API is not available'); } else { data = response.body.data; let price_usd = Number(data.current_price); From 5f825b9156594b49f1eefdf57e29138d898c2b2c Mon Sep 17 00:00:00 2001 From: YULIUS KURNIAWAN KRISTIANTO Date: Wed, 9 Oct 2019 23:41:33 +0700 Subject: [PATCH 17/48] update as niko request --- bot/modules/stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 20d2c7d..428878a 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -44,7 +44,7 @@ exports.stats = { msg.channel.send('coingecko API is not available'); } else { data = response.body.data; - let price_eur\ = Number(data.current_price); + let price_eur = Number(data.current_price); needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); From 37bd54f9210c7d3b40e83e4e25ccfdc4c62fed18 Mon Sep 17 00:00:00 2001 From: ProfessorDey Date: Wed, 9 Oct 2019 23:31:24 +0100 Subject: [PATCH 18/48] Fix !why typo causing build failure The !why commit seems to have included a typo as evidenced by the build failure logs, causing all other builds to fail: https://travis-ci.com/lbryio/lbry-wunderbot/builds/130782835 This simply replaces the missing bracket and comma. --- config/commands.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config/commands.json b/config/commands.json index 7426fdb..2345293 100644 --- a/config/commands.json +++ b/config/commands.json @@ -913,6 +913,7 @@ "icon_url": "https://spee.ch/2/pinkylbryheart.png" } } + }, "!piratebay": { "usage": "", From 28e95245b0c5ccc9752886718721eaeb9c35ae76 Mon Sep 17 00:00:00 2001 From: Ralph Date: Wed, 9 Oct 2019 20:28:26 -0400 Subject: [PATCH 19/48] Closed string to resolve travis build --- bot/modules/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 428878a..6cfe1ec 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -8,8 +8,8 @@ exports.stats = { usage: '', description: 'Displays list of current Market stats', process: function(bot, msg) { - needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d -', function(error, response) { + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d', function(error, response) + { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { From 61ee16ce6423f8f46bddfd09bf00024de510d8f7 Mon Sep 17 00:00:00 2001 From: Ralph Date: Wed, 9 Oct 2019 20:37:54 -0400 Subject: [PATCH 20/48] Resolved syntax issues. --- bot/modules/stats.js | 203 +++++++++++++++++++++---------------------- 1 file changed, 101 insertions(+), 102 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 6cfe1ec..e30e447 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -1,113 +1,112 @@ let needle = require('needle'); let statsurl = 'https://coinmarketcap.com/currencies/library-credit/'; exports.commands = [ - 'stats' // command that is in this file, every command needs it own export as shown below + 'stats' // command that is in this file, every command needs it own export as shown below ]; exports.stats = { - usage: '', - description: 'Displays list of current Market stats', - process: function(bot, msg) { - needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d', function(error, response) - { - if (error || response.statusCode !== 200) { - msg.channel.send('coingecko API is not available'); - } else { - let data = response.body.data; - let rank = data.market_cap_rank; - let price_btc = Number(data.current_price); - let market_cap_btc = Number(data.quotes.market_cap); - let circulating_supply = Number(data.circulating_supply); - let total_supply = Number(data.total_supply); - let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); - let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); - let volume24_btc = Number(data.total_volume); - let dt = new Date(); - let timestamp = dt.toUTCString(); - let hr_indicator = ':thumbsup:'; - let day_indicator = ':thumbsup:'; - if (percent_change_1h < 0) { - hr_indicator = ':thumbsdown:'; - } - if (percent_change_24h < 0) { - day_indicator = ':thumbsdown:'; - } - - needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=gbp&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { - if (error || response.statusCode !== 200) { - msg.channel.send('coingecko API is not available'); - } else { - data = response.body.data; - let price_gbp = Number(data.current_price); - needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { - if (error || response.statusCode !== 200) { + usage: '', + description: 'Displays list of current Market stats', + process: function(bot, msg) { + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d', function(error, response) { + if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); - } else { - data = response.body.data; - let price_eur = Number(data.current_price); - needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function(error, response) { - if (error || response.statusCode !== 200) { - msg.channel.send('coingecko API is not available'); - } else { - data = response.body.data; - let price_usd = Number(data.current_price); - let description = `**Rank: [${rank}](${statsurl})** -**Data** -Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) -Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl}) -Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl}) -24 Hour Volume: [$${volume24_usd}](${statsurl}) + } else { + let data = response.body.data; + let rank = data.market_cap_rank; + let price_btc = Number(data.current_price); + let market_cap_btc = Number(data.quotes.market_cap); + let circulating_supply = Number(data.circulating_supply); + let total_supply = Number(data.total_supply); + let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); + let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); + let volume24_btc = Number(data.total_volume); + let dt = new Date(); + let timestamp = dt.toUTCString(); + let hr_indicator = ':thumbsup:'; + let day_indicator = ':thumbsup:'; + if (percent_change_1h < 0) { + hr_indicator = ':thumbsdown:'; + } + if (percent_change_24h < 0) { + day_indicator = ':thumbsdown:'; + } -**Price** -BTC: [₿${price_btc.toFixed(8)}](${statsurl}) -USD: [$${price_usd.toFixed(2)}](${statsurl}) -EUR: [€${price_eur.toFixed(2)}](${statsurl}) -GBP: [£${price_gbp.toFixed(2)}](${statsurl}) + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=gbp&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) { + if (error || response.statusCode !== 200) { + msg.channel.send('coingecko API is not available'); + } else { + data = response.body.data; + let price_gbp = Number(data.current_price); + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) { + if (error || response.statusCode !== 200) { + msg.channel.send('coingecko API is not available'); + } else { + data = response.body.data; + let price_eur = Number(data.current_price); + needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) { + if (error || response.statusCode !== 200) { + msg.channel.send('coingecko API is not available'); + } else { + data = response.body.data; + let price_usd = Number(data.current_price); + let description = `**Rank: [${rank}](${statsurl})** + **Data** + Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) + Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl}) + Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl}) + 24 Hour Volume: [$${volume24_usd}](${statsurl}) + + **Price** + BTC: [₿${price_btc.toFixed(8)}](${statsurl}) + USD: [$${price_usd.toFixed(2)}](${statsurl}) + EUR: [€${price_eur.toFixed(2)}](${statsurl}) + GBP: [£${price_gbp.toFixed(2)}](${statsurl}) + + **% Change** + 1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator} + + 1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator}`; + const embed = { + description: description, + color: 7976557, + footer: { + text: 'Last Updated: ' + timestamp + }, + author: { + name: 'Coin Market Cap Stats (LBC)', + url: statsurl, + icon_url: 'https://spee.ch/2/pinkylbryheart.png' + } + }; + msg.channel.send({embed}); + } + }); + } + }); + } + }); -**% Change** -1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator} + function parse_obj(obj) { + let array = []; + let prop; + for (prop in obj) { + if (obj.hasOwnProperty(prop)) { + let key = parseInt(prop, 10); + let value = obj[prop]; + if (typeof value == 'object') { + value = parse_obj(value); + } + array[key] = value; + } + } + return array; + } -1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator} - -`; - const embed = { - description: description, - color: 7976557, - footer: { - text: 'Last Updated: ' + timestamp - }, - author: { - name: 'Coin Market Cap Stats (LBC)', - url: statsurl, - icon_url: 'https://spee.ch/2/pinkylbryheart.png' - } - }; - msg.channel.send({ embed }); - } - }); - } - }); - } - }); - - function parse_obj(obj) { - let array = []; - let prop; - for (prop in obj) { - if (obj.hasOwnProperty(prop)) { - let key = parseInt(prop, 10); - let value = obj[prop]; - if (typeof value == 'object') { - value = parse_obj(value); - } - array[key] = value; - } - } - return array; + function numberWithCommas(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); + } + } + }) } - - function numberWithCommas(x) { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); - } - } -}; +} From 72cee0943e7aad612eb024fbaa305dcc8db777eb Mon Sep 17 00:00:00 2001 From: Ralph Date: Wed, 9 Oct 2019 20:40:32 -0400 Subject: [PATCH 21/48] Correct syntax --- config/commands.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/commands.json b/config/commands.json index 7426fdb..86ab81e 100644 --- a/config/commands.json +++ b/config/commands.json @@ -912,7 +912,7 @@ "url": "https://lbry.com/faq", "icon_url": "https://spee.ch/2/pinkylbryheart.png" } - } + }, "!piratebay": { "usage": "", From ce3bfb87e9fa63b25f99137760ea89bff64afb3a Mon Sep 17 00:00:00 2001 From: ProfessorDey Date: Thu, 10 Oct 2019 22:05:22 +0100 Subject: [PATCH 22/48] Neaten up Definitions Just a little adjustment to cut out a few unnecessary lines where an inline ternary operator would do. --- bot/modules/stats.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index e30e447..9f6b12a 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -23,14 +23,8 @@ exports.stats = { let volume24_btc = Number(data.total_volume); let dt = new Date(); let timestamp = dt.toUTCString(); - let hr_indicator = ':thumbsup:'; - let day_indicator = ':thumbsup:'; - if (percent_change_1h < 0) { - hr_indicator = ':thumbsdown:'; - } - if (percent_change_24h < 0) { - day_indicator = ':thumbsdown:'; - } + let hr_indicator = (percent_change_1h < 0) ? ':thumbsdown:' : ':thumbsup:'; + let day_indicator = (percent_change_24h < 0) ? ':thumbsdown:' : ':thumbsup:'; needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=gbp&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) { if (error || response.statusCode !== 200) { From 90f7b9127487d543638711d76eb1177199507eef Mon Sep 17 00:00:00 2001 From: felhe <10731299+felhe@users.noreply.github.com> Date: Thu, 10 Oct 2019 23:42:20 +0200 Subject: [PATCH 23/48] Fix crashing at role commands in private DMs --- bot/modules/rolesetter.js | 79 ++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 43 deletions(-) diff --git a/bot/modules/rolesetter.js b/bot/modules/rolesetter.js index af7351e..824635f 100644 --- a/bot/modules/rolesetter.js +++ b/bot/modules/rolesetter.js @@ -13,77 +13,70 @@ exports.addrole = { usage: '', description: 'Adds you to specified role', process: function(bot, msg, suffix) { + // Provide shortened syntax for the sake of code cleanliness + let send = msgTxt => { + msg.channel.send(msgTxt); + return; + }; + // Checks if the user has messaged the bot via Direct Message + if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + // Here the bot, msg and suffix is avaible, this function can be async if needed. // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. let newrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); // Baserole is assumed to already be case accurate as it's handled in the config itself. let baserole = msg.guild.roles.find('name', rolelist.baserole); - - // Provide shortened syntax for the sake of code cleanliness - let send = (msgTxt) => { msg.channel.send(msgTxt); return; }; - let rolecmd = botconfig.prefix + "roles"; - - // Checks if the user has messaged the bot via Direct Message - if (inPrivate(msg)) - return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + + let rolecmd = botconfig.prefix + 'roles'; + // Checks if the user included a role in their message - if (!suffix) - return send("Please specify a role. Type " + rolecmd + " to see which you may add yourself!"); + if (!suffix) return send('Please specify a role. Type ' + rolecmd + ' to see which you may add yourself!'); // Checks if there is a matching role found on the server - if(!newrole) - return send("The role specified `" + suffix + "` does not exist on this server!"); + if (!newrole) return send('The role specified `' + suffix + '` does not exist on this server!'); // Checks that the allowed roles and base role against the matched role's name, since this eliminates case sensitivity issues - if(!rolelist.allowedroles.includes(newrole.name) && !rolelist.baserole.includes(newrole.name)) - return send("That role isn't one you can add yourself to! Type " + rolecmd + " command to find out which ones are allowed."); + if (!rolelist.allowedroles.includes(newrole.name) && !rolelist.baserole.includes(newrole.name)) return send("That role isn't one you can add yourself to! Type " + rolecmd + ' command to find out which ones are allowed.'); // Use the matched name to check against the member's existing roles - if(msg.member.roles.find('name', newrole.name)) - return send("It seems you already have the " + newrole.name + "role"); - + if (msg.member.roles.find('name', newrole.name)) return send('It seems you already have the ' + newrole.name + 'role'); + // Assuming all these factors succeed, add the role - msg.member.addRole(newrole).then(send(msg.member + " has been added to the " + newrole.name + " role!")); - + msg.member.addRole(newrole).then(send(msg.member + ' has been added to the ' + newrole.name + ' role!')); + // Check if a baserole is actually set - if(!rolelist.baserole) - return; + if (!rolelist.baserole) return; // Confirm that the role exists on the server and if not then be sure to send a nag message - if(!baserole) - return send("The base role of " + rolelist.baserole + " has been set in config but is missing from the server"); + if (!baserole) return send('The base role of ' + rolelist.baserole + ' has been set in config but is missing from the server'); // Confirm if the user has the baserole already, including if it was added just now - if(msg.member.roles.find('name', baserole.name)) - return; + if (msg.member.roles.find('name', baserole.name)) return; // Add the base role and avoid spamming the user by only mentioning them in the previous message - msg.member.addRole(baserole).then(send("We also added the base " + rolelist.baserole + " role for you!")); + msg.member.addRole(baserole).then(send('We also added the base ' + rolelist.baserole + ' role for you!')); } }; exports.delrole = { usage: '', description: 'Deletes the specified role from your account', process: function(bot, msg, suffix) { + // Provide shortened syntax for the sake of code cleanliness + let send = msgTxt => { + msg.channel.send(msgTxt); + return; + }; + // Checks if the user has messaged the bot via Direct Message + if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.'); // Here in the bot, msg and suffix are available, this function can be async if needed. // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. let oldrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); - // Provide shortened syntax for the sake of code cleanliness - let send = (msgTxt) => { msg.channel.send(msgTxt); return; }; - let rolecmd = botconfig.prefix + "roles"; - - // Checks if the user has messaged the bot via Direct Message - if (inPrivate(msg)) - return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + let rolecmd = botconfig.prefix + 'roles'; // Checks if the user included a role in their message - if (!suffix) - return send("Please specify a role. Type " + rolecmd + " to see which you may remove yourself!"); + if (!suffix) return send('Please specify a role. Type ' + rolecmd + ' to see which you may remove yourself!'); // Checks if there is a matching role found on the server - if(!newrole) - return send("The role specified `" + suffix + "` does not exist on this server!"); + if (!oldrole) return send('The role specified `' + suffix + '` does not exist on this server!'); // Checks that the allowed roles against the matched role's name, since this eliminates case sensitivity issues - if(!rolelist.allowedroles.includes(oldrole.name)) - return send("That role isn't one you can remove yourself! If you need it removed, please ask a moderator!"); + if (!rolelist.allowedroles.includes(oldrole.name)) return send("That role isn't one you can remove yourself! If you need it removed, please ask a moderator!"); // Use the matched name to check against the member's existing roles - if(!msg.member.roles.find('name', oldrole.name)) - return send("It seems you don't actually have the " + oldrole.name + "role! Mission accomplished!"); - + if (!msg.member.roles.find('name', oldrole.name)) return send("It seems you don't actually have the " + oldrole.name + 'role! Mission accomplished!'); + // Assuming all these factors succeed, add the role - msg.member.removeRole(oldrole).then(send(msg.member + " has been removed from the " + oldrole.name + " role!")); + msg.member.removeRole(oldrole).then(send(msg.member + ' has been removed from the ' + oldrole.name + ' role!')); } }; exports.roles = { From f7bb1cb942a3f4e3386134c1e00fea701a679655 Mon Sep 17 00:00:00 2001 From: felhe <10731299+felhe@users.noreply.github.com> Date: Fri, 11 Oct 2019 01:00:15 +0200 Subject: [PATCH 24/48] Simplify expressions in rolesetter --- bot/modules/rolesetter.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/bot/modules/rolesetter.js b/bot/modules/rolesetter.js index 824635f..297aeb5 100644 --- a/bot/modules/rolesetter.js +++ b/bot/modules/rolesetter.js @@ -14,10 +14,7 @@ exports.addrole = { description: 'Adds you to specified role', process: function(bot, msg, suffix) { // Provide shortened syntax for the sake of code cleanliness - let send = msgTxt => { - msg.channel.send(msgTxt); - return; - }; + let send = msgTxt => msg.channel.send(msgTxt); // Checks if the user has messaged the bot via Direct Message if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.'); @@ -25,7 +22,7 @@ exports.addrole = { // Make sure to eliminate case sensitivity, do this here to only perform the sweep once. let newrole = msg.guild.roles.find(role => role.name.toLowerCase() === suffix.toLowerCase()); // Baserole is assumed to already be case accurate as it's handled in the config itself. - let baserole = msg.guild.roles.find('name', rolelist.baserole); + let baserole = msg.guild.roles.find(item => item.name === rolelist.baserole); let rolecmd = botconfig.prefix + 'roles'; @@ -36,7 +33,7 @@ exports.addrole = { // Checks that the allowed roles and base role against the matched role's name, since this eliminates case sensitivity issues if (!rolelist.allowedroles.includes(newrole.name) && !rolelist.baserole.includes(newrole.name)) return send("That role isn't one you can add yourself to! Type " + rolecmd + ' command to find out which ones are allowed.'); // Use the matched name to check against the member's existing roles - if (msg.member.roles.find('name', newrole.name)) return send('It seems you already have the ' + newrole.name + 'role'); + if (msg.member.roles.find(item => item.name === newrole.name)) return send('It seems you already have the ' + newrole.name + 'role'); // Assuming all these factors succeed, add the role msg.member.addRole(newrole).then(send(msg.member + ' has been added to the ' + newrole.name + ' role!')); @@ -46,7 +43,7 @@ exports.addrole = { // Confirm that the role exists on the server and if not then be sure to send a nag message if (!baserole) return send('The base role of ' + rolelist.baserole + ' has been set in config but is missing from the server'); // Confirm if the user has the baserole already, including if it was added just now - if (msg.member.roles.find('name', baserole.name)) return; + if (msg.member.roles.find(item => item.name === baserole.name)) return; // Add the base role and avoid spamming the user by only mentioning them in the previous message msg.member.addRole(baserole).then(send('We also added the base ' + rolelist.baserole + ' role for you!')); } @@ -56,10 +53,7 @@ exports.delrole = { description: 'Deletes the specified role from your account', process: function(bot, msg, suffix) { // Provide shortened syntax for the sake of code cleanliness - let send = msgTxt => { - msg.channel.send(msgTxt); - return; - }; + let send = msgTxt => msg.channel.send(msgTxt); // Checks if the user has messaged the bot via Direct Message if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.'); // Here in the bot, msg and suffix are available, this function can be async if needed. @@ -73,7 +67,7 @@ exports.delrole = { // Checks that the allowed roles against the matched role's name, since this eliminates case sensitivity issues if (!rolelist.allowedroles.includes(oldrole.name)) return send("That role isn't one you can remove yourself! If you need it removed, please ask a moderator!"); // Use the matched name to check against the member's existing roles - if (!msg.member.roles.find('name', oldrole.name)) return send("It seems you don't actually have the " + oldrole.name + 'role! Mission accomplished!'); + if (!msg.member.roles.find(item => item.name === oldrole.name)) return send("It seems you don't actually have the " + oldrole.name + 'role! Mission accomplished!'); // Assuming all these factors succeed, add the role msg.member.removeRole(oldrole).then(send(msg.member + ' has been removed from the ' + oldrole.name + ' role!')); @@ -83,12 +77,11 @@ exports.roles = { usage: '', description: 'displays roles you can give yourself', process: function(bot, msg, suffix) { - if (inPrivate(msg)) { - msg.channel.send('You can not set roles in DMs! Please go to the Discord server to do this.'); - return; - } else { + let send = msgTxt => msg.channel.send(msgTxt); + if (inPrivate(msg)) return send('You can not set roles in DMs! Please go to the Discord server to do this.'); + else { // Here in the bot, msg and suffix are available, this function can be async if needed. - msg.channel.send({ + send({ embed: { color: 3447003, title: 'Wunderbot', @@ -121,7 +114,6 @@ exports.roles = { } } }); - //msg.channel.send(JSON.stringify(rolelist.allowedroles)); } } }; From 9720ece9a4103bda2aebedbedcdcfe97d8135130 Mon Sep 17 00:00:00 2001 From: Kenneth C Date: Fri, 11 Oct 2019 20:58:15 +0100 Subject: [PATCH 25/48] Update stat.js to show 5 decimal value fiat prices. Update stat.js to show 5 decimal value fiat prices due to recent price dropping below the 2 decimal values previously. --- bot/modules/stats.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 9f6b12a..e5631ea 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -1,26 +1,26 @@ let needle = require('needle'); -let statsurl = 'https://coinmarketcap.com/currencies/library-credit/'; +let statsurl = 'https://www.coingecko.com/en/coins/lbry-credits'; exports.commands = [ 'stats' // command that is in this file, every command needs it own export as shown below ]; exports.stats = { usage: '', - description: 'Displays list of current Market stats', + description: 'Displays list of Current Market Statistics', process: function(bot, msg) { needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=24h%2C1h%2C7d', function(error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { - let data = response.body.data; + console.log(response); + console.log(response.body[0]); + let data = response.body[0]; let rank = data.market_cap_rank; let price_btc = Number(data.current_price); - let market_cap_btc = Number(data.quotes.market_cap); let circulating_supply = Number(data.circulating_supply); let total_supply = Number(data.total_supply); let percent_change_1h = Number(data.price_change_percentage_1h_in_currency); let percent_change_24h = Number(data.price_change_percentage_24h_in_currency); - let volume24_btc = Number(data.total_volume); let dt = new Date(); let timestamp = dt.toUTCString(); let hr_indicator = (percent_change_1h < 0) ? ':thumbsdown:' : ':thumbsup:'; @@ -30,37 +30,39 @@ exports.stats = { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { - data = response.body.data; + data = response.body[0]; let price_gbp = Number(data.current_price); needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { - data = response.body.data; + data = response.body[0]; let price_eur = Number(data.current_price); needle.get('https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=lbry-credits&order=market_cap_desc&per_page=100&page=1&sparkline=false', function (error, response) { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { - data = response.body.data; + data = response.body[0]; let price_usd = Number(data.current_price); + let market_cap_usd = Number(data.market_cap); + let volume24_usd = Number(data.total_volume); let description = `**Rank: [${rank}](${statsurl})** **Data** Market Cap: [$${numberWithCommas(market_cap_usd)}](${statsurl}) Total Supply: [${numberWithCommas(total_supply)} LBC](${statsurl}) - Circulating Supply: [${numberWithCommas(circulating_supply)} LBC](${statsurl}) - 24 Hour Volume: [$${volume24_usd}](${statsurl}) + Circulating Supply: [${numberWithCommas(circulating_supply.toFixed(0))} LBC](${statsurl}) + 24 Hour Volume: [$${numberWithCommas(volume24_usd)}](${statsurl}) **Price** BTC: [₿${price_btc.toFixed(8)}](${statsurl}) - USD: [$${price_usd.toFixed(2)}](${statsurl}) - EUR: [€${price_eur.toFixed(2)}](${statsurl}) - GBP: [£${price_gbp.toFixed(2)}](${statsurl}) + USD: [$${price_usd.toFixed(5)}](${statsurl}) + EUR: [€${price_eur.toFixed(5)}](${statsurl}) + GBP: [£${price_gbp.toFixed(5)}](${statsurl}) **% Change** - 1 Hour: [${percent_change_1h}](${statsurl}) ${hr_indicator} + 1 Hour: [${percent_change_1h.toFixed(2)}%](${statsurl}) ${hr_indicator} - 1 Day: [${percent_change_24h}](${statsurl}) ${day_indicator}`; + 1 Day: [${percent_change_24h.toFixed(2)}%](${statsurl}) ${day_indicator}`; const embed = { description: description, color: 7976557, @@ -68,7 +70,7 @@ exports.stats = { text: 'Last Updated: ' + timestamp }, author: { - name: 'Coin Market Cap Stats (LBC)', + name: 'Coin Gecko Stats (LBC)', url: statsurl, icon_url: 'https://spee.ch/2/pinkylbryheart.png' } @@ -104,3 +106,4 @@ exports.stats = { }) } } + From a71e59fb6327ec7a888ec54ebe3ade5122aac278 Mon Sep 17 00:00:00 2001 From: Ralph Date: Sun, 13 Oct 2019 01:41:08 -0400 Subject: [PATCH 26/48] Removed Console Logging of return data. --- bot/modules/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index e5631ea..488fb56 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -12,8 +12,8 @@ exports.stats = { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { - console.log(response); - console.log(response.body[0]); + //console.log(response); + //console.log(response.body[0]); let data = response.body[0]; let rank = data.market_cap_rank; let price_btc = Number(data.current_price); From 2676f35a5bc888b2fb2bed70025399421edc67dd Mon Sep 17 00:00:00 2001 From: Ralph Date: Sun, 13 Oct 2019 01:43:05 -0400 Subject: [PATCH 27/48] Update stats.js --- bot/modules/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/stats.js b/bot/modules/stats.js index 488fb56..dea6775 100644 --- a/bot/modules/stats.js +++ b/bot/modules/stats.js @@ -12,8 +12,8 @@ exports.stats = { if (error || response.statusCode !== 200) { msg.channel.send('coingecko API is not available'); } else { - //console.log(response); - //console.log(response.body[0]); + // console.log(response); + // console.log(response.body[0]); let data = response.body[0]; let rank = data.market_cap_rank; let price_btc = Number(data.current_price); From f0454fbbfb6a4dbaf9cfef1de980efa106cb6134 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 22:12:03 -0400 Subject: [PATCH 28/48] Add post check for channel postings --- bot/modules/releasenotes.js | 204 ++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 2fafa08..669ac31 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -5,111 +5,111 @@ let inPrivate = require('../helpers.js').inPrivate; let ChannelID = config.get('gitrelease').channel; exports.commands = [ - 'releasenotes' // command that is in this file, every command needs it own export as shown below + 'releasenotes' // command that is in this file, every command needs it own export as shown below ]; exports.releasenotes = { - usage: '', - description: 'gets current release notes from GitHub, for either Desktop or Android', - 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 = { - 'Content-Type': 'application/json', - 'User-Agent': 'Super Agent/0.0.1' - }; - // Configure the request - const options = { - url: 'https://api.github.com/repos/lbryio/lbry-' + releaseType + '/releases/latest', - method: 'GET', - headers: headers - }; - // Start the request - let message; - request(options, function(error, response, body) { - let json = JSON.parse(body); - let releasemessage = json.body; - let releasename = json.name || json.tag_name; - let releasedate = json.published_at; - let releaseurl = json.html_url; - if (releasemessage.length < 2000) { - message = { - embed: { - title: '*Download ' + releasename + ' here!*', - description: releasemessage.replace('###', ''), - url: releaseurl, - color: 7976557, - timestamp: releasedate, - author: { - name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, - icon_url: 'https://spee.ch/b/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' - } - } + usage: '', + description: 'gets current release notes from GitHub, for either Desktop or Android', + 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 = { + 'Content-Type': 'application/json', + 'User-Agent': 'Super Agent/0.0.1' }; - if (inPrivate(msg)) { - msg.channel.send(message); - return; - } - if (hasPerms(msg) && suffix === 'post') { - bot.channels.get(ChannelID).send(message); - } else { - msg.channel.send(msg.author + ' Release notes sent via DM'); - msg.author.send(message); - } - } else { - message = releasemessage - .trim() - .split('###') - .filter(function(n) { - return n !== ''; - }); - let embedmessages = []; - for (let i = 0; i < message.length; i++) { - if (message[i]) { - embedmessages.push({ - embed: { - description: message[i], - url: releaseurl, - color: 7976557, - timestamp: releasedate, - author: { - name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, - icon_url: 'https://spee.ch/b/Github-PNG-Image.png' - }, - footer: { - icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' + // Configure the request + const options = { + url: 'https://api.github.com/repos/lbryio/lbry-' + releaseType + '/releases/latest', + method: 'GET', + headers: headers + }; + // Start the request + let message; + request(options, function(error, response, body) { + let json = JSON.parse(body); + let releasemessage = json.body; + let releasename = json.name || json.tag_name; + let releasedate = json.published_at; + let releaseurl = json.html_url; + if (releasemessage.length < 2000) { + message = { + embed: { + title: '*Download ' + releasename + ' here!*', + description: releasemessage.replace('###', ''), + url: releaseurl, + color: 7976557, + timestamp: releasedate, + author: { + name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, + icon_url: 'https://spee.ch/b/Github-PNG-Image.png' + }, + footer: { + icon_url: 'https://spee.ch/2/pinkylbryheart.png', + text: 'LBRY ' + releaseTypeName + ' updated ' + } + } + }; + if (inPrivate(msg)) { + msg.channel.send(message); + return; } - } - }); - if (i === 0) embedmessages[i].embed.title = '*Download ' + releasename + ' here!*'; - } - } - if (inPrivate(msg)) { - for (let i = 0; i < embedmessages.length; i++) { - msg.channel.send(embedmessages[i]); - } - return; - } - if (hasPerms(msg) && suffix === 'post') { - for (let i = 0; i < embedmessages.length; i++) { - bot.channels.get(ChannelID).send(embedmessages[i]); - } - } else { - msg.channel.send(msg.author + ' Release notes sent via DM'); - for (let i = 0; i < embedmessages.length; i++) { - msg.author.send(embedmessages[i]); - } - } - } - }); - } + if (hasPerms(msg) && suffix === ' android post' || 'desktop post') { + bot.channels.get(ChannelID).send(message); + } else { + msg.channel.send(msg.author + ' Release notes sent via DM'); + msg.author.send(message); + } + } else { + message = releasemessage + .trim() + .split('###') + .filter(function(n) { + return n !== ''; + }); + let embedmessages = []; + for (let i = 0; i < message.length; i++) { + if (message[i]) { + embedmessages.push({ + embed: { + description: message[i], + url: releaseurl, + color: 7976557, + timestamp: releasedate, + author: { + name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, + icon_url: 'https://spee.ch/b/Github-PNG-Image.png' + }, + footer: { + icon_url: 'https://spee.ch/2/pinkylbryheart.png', + text: 'LBRY ' + releaseTypeName + ' updated ' + } + } + }); + if (i === 0) embedmessages[i].embed.title = '*Download ' + releasename + ' here!*'; + } + } + if (inPrivate(msg)) { + for (let i = 0; i < embedmessages.length; i++) { + msg.channel.send(embedmessages[i]); + } + return; + } + if (hasPerms(msg) && suffix === 'android post' || 'desktop post') { + for (let i = 0; i < embedmessages.length; i++) { + bot.channels.get(ChannelID).send(embedmessages[i]); + } + } else { + msg.channel.send(msg.author + ' Release notes sent via DM'); + for (let i = 0; i < embedmessages.length; i++) { + msg.author.send(embedmessages[i]); + } + } + } + }); + } }; From e37c4fcf2e5b1879236bde3a1230c68a3b8adaf5 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:02:37 -0400 Subject: [PATCH 29/48] Update releasenotes.js --- bot/modules/releasenotes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 669ac31..bbef3f6 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -58,7 +58,7 @@ exports.releasenotes = { msg.channel.send(message); return; } - if (hasPerms(msg) && suffix === ' android post' || 'desktop post') { + if (hasPerms(msg) && suffix === releaseTypeName + ' post') { bot.channels.get(ChannelID).send(message); } else { msg.channel.send(msg.author + ' Release notes sent via DM'); @@ -99,7 +99,7 @@ exports.releasenotes = { } return; } - if (hasPerms(msg) && suffix === 'android post' || 'desktop post') { + if (hasPerms(msg) && suffix === releaseTypeName + ' post') { for (let i = 0; i < embedmessages.length; i++) { bot.channels.get(ChannelID).send(embedmessages[i]); } From 6dbddb68cf0234e725effe24196a56f41df8ed07 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:12:31 -0400 Subject: [PATCH 30/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index bbef3f6..d25aca9 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -14,7 +14,7 @@ exports.releasenotes = { process: function(bot, msg, suffix) { let releaseType = suffix.toLowerCase(); let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); - if (releaseType !== 'android' && releaseType !== 'desktop') { + if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android push' && releaseType !== 'desktop push') { msg.reply('Please specify which release notes to display: "desktop" or "android".'); return; } From bfd7569c5659e098519de1011bafef86a61d7fb2 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:13:58 -0400 Subject: [PATCH 31/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index d25aca9..7b30af1 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -14,7 +14,7 @@ exports.releasenotes = { process: function(bot, msg, suffix) { let releaseType = suffix.toLowerCase(); let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); - if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android push' && releaseType !== 'desktop push') { + if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android post' && releaseType !== 'desktop post') { msg.reply('Please specify which release notes to display: "desktop" or "android".'); return; } From 205428f371bec560f2437782df1874f5f8a082c7 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:18:13 -0400 Subject: [PATCH 32/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 7b30af1..2e6acc2 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -24,7 +24,7 @@ exports.releasenotes = { }; // Configure the request const options = { - url: 'https://api.github.com/repos/lbryio/lbry-' + releaseType + '/releases/latest', + url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypeName + '/releases/latest', method: 'GET', headers: headers }; From 4c01ff50f84fd7a79ccf1a26f690743dbc89975d Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:20:58 -0400 Subject: [PATCH 33/48] enable logging --- bot/modules/releasenotes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 2e6acc2..659b64f 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -33,6 +33,7 @@ exports.releasenotes = { request(options, function(error, response, body) { let json = JSON.parse(body); let releasemessage = json.body; + console.log(releasemessage); let releasename = json.name || json.tag_name; let releasedate = json.published_at; let releaseurl = json.html_url; From 933e6be92676f6093155b677309f984846170c79 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:22:37 -0400 Subject: [PATCH 34/48] Update releasenotes.js --- bot/modules/releasenotes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 659b64f..4c3568f 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -24,6 +24,7 @@ exports.releasenotes = { }; // Configure the request const options = { + console.log('Release being sent: ' + releaseTypeName); url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypeName + '/releases/latest', method: 'GET', headers: headers From 26d554577b689e8813948a268ed53ad850b6034f Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:25:03 -0400 Subject: [PATCH 35/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 4c3568f..c18806a 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -23,8 +23,8 @@ exports.releasenotes = { 'User-Agent': 'Super Agent/0.0.1' }; // Configure the request + console.log('Release being sent: ' + releaseTypeName); const options = { - console.log('Release being sent: ' + releaseTypeName); url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypeName + '/releases/latest', method: 'GET', headers: headers From 18fd37134c197a7dfd5733fc4676c8f248164c79 Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:34:03 -0400 Subject: [PATCH 36/48] Update releasenotes.js --- bot/modules/releasenotes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index c18806a..9404590 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -13,8 +13,8 @@ exports.releasenotes = { description: 'gets current release notes from GitHub, for either Desktop or Android', process: function(bot, msg, suffix) { let releaseType = suffix.toLowerCase(); - let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); - if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android post' && releaseType !== 'desktop post') { + let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(5); + if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'post android' && releaseType !== 'post desktop') { msg.reply('Please specify which release notes to display: "desktop" or "android".'); return; } @@ -60,7 +60,7 @@ exports.releasenotes = { msg.channel.send(message); return; } - if (hasPerms(msg) && suffix === releaseTypeName + ' post') { + if (hasPerms(msg) && suffix === 'post ' + releaseTypeName) { bot.channels.get(ChannelID).send(message); } else { msg.channel.send(msg.author + ' Release notes sent via DM'); @@ -100,8 +100,8 @@ exports.releasenotes = { msg.channel.send(embedmessages[i]); } return; - } - if (hasPerms(msg) && suffix === releaseTypeName + ' post') { + } + if (hasPerms(msg) && suffix === 'post ' + releaseTypeName) { for (let i = 0; i < embedmessages.length; i++) { bot.channels.get(ChannelID).send(embedmessages[i]); } From ba963844d6dc9bef06b031b2ab298b8d146d804e Mon Sep 17 00:00:00 2001 From: Ralph Date: Thu, 17 Oct 2019 23:37:07 -0400 Subject: [PATCH 37/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 9404590..506d3ab 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -13,7 +13,7 @@ exports.releasenotes = { description: 'gets current release notes from GitHub, for either Desktop or Android', process: function(bot, msg, suffix) { let releaseType = suffix.toLowerCase(); - let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(5); + let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'post android' && releaseType !== 'post desktop') { msg.reply('Please specify which release notes to display: "desktop" or "android".'); return; From e69d4662accf2de093f16aeded496d9b826de79e Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:10:41 -0400 Subject: [PATCH 38/48] Update releasenotes.js --- bot/modules/releasenotes.js | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 506d3ab..6d83587 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -13,8 +13,13 @@ exports.releasenotes = { description: 'gets current release notes from GitHub, for either Desktop or Android', process: function(bot, msg, suffix) { let releaseType = suffix.toLowerCase(); + let releaseTypePost = null; + if (releaseType === 'android post' || 'desktop post') { + let releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(-5); + break; + } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); - if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'post android' && releaseType !== 'post desktop') { + if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android post' && releaseType !== 'desktop post') { msg.reply('Please specify which release notes to display: "desktop" or "android".'); return; } @@ -23,12 +28,20 @@ exports.releasenotes = { 'User-Agent': 'Super Agent/0.0.1' }; // Configure the request - console.log('Release being sent: ' + releaseTypeName); - const options = { - url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypeName + '/releases/latest', - method: 'GET', - headers: headers - }; + if (releaseTypePost !== null) { + const options = { + url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypePost + '/releases/latest', + method: 'GET', + headers: headers + }; + } else { + console.log('Release being sent: ' + releaseTypeName); + const options = { + url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypeName + '/releases/latest', + method: 'GET', + headers: headers + }; + } // Start the request let message; request(options, function(error, response, body) { @@ -47,12 +60,12 @@ exports.releasenotes = { color: 7976557, timestamp: releasedate, author: { - name: 'LBRY ' + releaseTypeName + ' release notes for ' + releasename, + name: 'LBRY ' + releaseType + ' release notes for ' + releasename, icon_url: 'https://spee.ch/b/Github-PNG-Image.png' }, footer: { icon_url: 'https://spee.ch/2/pinkylbryheart.png', - text: 'LBRY ' + releaseTypeName + ' updated ' + text: 'LBRY ' + releaseType + ' updated ' } } }; @@ -60,7 +73,7 @@ exports.releasenotes = { msg.channel.send(message); return; } - if (hasPerms(msg) && suffix === 'post ' + releaseTypeName) { + if (hasPerms(msg) && suffix === releaseTypeName + ' post') { bot.channels.get(ChannelID).send(message); } else { msg.channel.send(msg.author + ' Release notes sent via DM'); @@ -101,7 +114,7 @@ exports.releasenotes = { } return; } - if (hasPerms(msg) && suffix === 'post ' + releaseTypeName) { + if (hasPerms(msg) && suffix === releaseTypeName + ' post') { for (let i = 0; i < embedmessages.length; i++) { bot.channels.get(ChannelID).send(embedmessages[i]); } From 1d6cb510be2569c78e426ff3a879fc15eaab7862 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:11:35 -0400 Subject: [PATCH 39/48] Update releasenotes.js --- bot/modules/releasenotes.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 6d83587..16a3a64 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -16,7 +16,6 @@ exports.releasenotes = { let releaseTypePost = null; if (releaseType === 'android post' || 'desktop post') { let releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(-5); - break; } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android post' && releaseType !== 'desktop post') { From 20cc8528e74fb9e86732167db00d0577c1950162 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:27:43 -0400 Subject: [PATCH 40/48] Update releasenotes.js --- bot/modules/releasenotes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 16a3a64..37f6877 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -27,15 +27,16 @@ exports.releasenotes = { 'User-Agent': 'Super Agent/0.0.1' }; // Configure the request + let options; if (releaseTypePost !== null) { - const options = { + options = { url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypePost + '/releases/latest', method: 'GET', headers: headers }; } else { console.log('Release being sent: ' + releaseTypeName); - const options = { + options = { url: 'https://api.github.com/repos/lbryio/lbry-' + releaseTypeName + '/releases/latest', method: 'GET', headers: headers From af31eacb8ef5d301ae168b88d76190869a95d4d5 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:32:35 -0400 Subject: [PATCH 41/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 37f6877..b79d217 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -15,7 +15,7 @@ exports.releasenotes = { let releaseType = suffix.toLowerCase(); let releaseTypePost = null; if (releaseType === 'android post' || 'desktop post') { - let releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(-5); + releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(-5); } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android post' && releaseType !== 'desktop post') { From 4e7625ce6e286af548a8e442d92a5832e17b54ea Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:33:56 -0400 Subject: [PATCH 42/48] Update releasenotes.js --- bot/modules/releasenotes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index b79d217..04ff01a 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -16,6 +16,7 @@ exports.releasenotes = { let releaseTypePost = null; if (releaseType === 'android post' || 'desktop post') { releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(-5); + console.log('Post message detected ' + releaseTypePost); } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); if (releaseType !== 'android' && releaseType !== 'desktop' && releaseType !== 'android post' && releaseType !== 'desktop post') { From fa6c92011eb6e749a2574a76a751e7092c9d60c9 Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:35:12 -0400 Subject: [PATCH 43/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 04ff01a..0535e56 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -15,7 +15,7 @@ exports.releasenotes = { let releaseType = suffix.toLowerCase(); let releaseTypePost = null; if (releaseType === 'android post' || 'desktop post') { - releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(-5); + releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(7); console.log('Post message detected ' + releaseTypePost); } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); From a645070cdd03a5fd400b0be4aa374a1ed4895d2b Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:37:00 -0400 Subject: [PATCH 44/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index 0535e56..bda0a24 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -15,7 +15,7 @@ exports.releasenotes = { let releaseType = suffix.toLowerCase(); let releaseTypePost = null; if (releaseType === 'android post' || 'desktop post') { - releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(7); + releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(0,7); console.log('Post message detected ' + releaseTypePost); } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); From 931bc0af8ed55a66cd3d6aba740bbb1e380c7f8a Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:38:30 -0400 Subject: [PATCH 45/48] Update releasenotes.js --- bot/modules/releasenotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index bda0a24..bbe87ce 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -15,7 +15,7 @@ exports.releasenotes = { let releaseType = suffix.toLowerCase(); let releaseTypePost = null; if (releaseType === 'android post' || 'desktop post') { - releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(0,7); + releaseTypePost = releaseType.charAt(0).toUpperCase() + releaseType.slice(1,7); console.log('Post message detected ' + releaseTypePost); } let releaseTypeName = releaseType.charAt(0).toUpperCase() + releaseType.slice(1); From 3e3af97b433ab12b0009908af1aaac6bc971ff8d Mon Sep 17 00:00:00 2001 From: Ralph Date: Fri, 18 Oct 2019 00:45:44 -0400 Subject: [PATCH 46/48] Update releasenotes.js --- bot/modules/releasenotes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/releasenotes.js b/bot/modules/releasenotes.js index bbe87ce..9910046 100644 --- a/bot/modules/releasenotes.js +++ b/bot/modules/releasenotes.js @@ -74,7 +74,7 @@ exports.releasenotes = { msg.channel.send(message); return; } - if (hasPerms(msg) && suffix === releaseTypeName + ' post') { + if (hasPerms(msg) && suffix === 'android post' || 'desktop post') { bot.channels.get(ChannelID).send(message); } else { msg.channel.send(msg.author + ' Release notes sent via DM'); @@ -115,7 +115,7 @@ exports.releasenotes = { } return; } - if (hasPerms(msg) && suffix === releaseTypeName + ' post') { + if (hasPerms(msg) && suffix === 'android post' || 'desktop post') { for (let i = 0; i < embedmessages.length; i++) { bot.channels.get(ChannelID).send(embedmessages[i]); } From 61dbeb8fe8bd200cef6efd60738707f4345193d6 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Fri, 15 Nov 2019 11:04:51 -0500 Subject: [PATCH 47/48] disable announcing claims --- bot/modules/claimbot.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/bot/modules/claimbot.js b/bot/modules/claimbot.js index 3b48c93..b48d063 100644 --- a/bot/modules/claimbot.js +++ b/bot/modules/claimbot.js @@ -20,8 +20,6 @@ function init(discordBot_) { discordBot = discordBot_; console.log('Activating claimbot'); discordBot.channels.get(channels[0]).send('activating claimbot'); - setInterval(announceClaims, 60 * 1000); - announceClaims(); } function announceClaims() { From 267128b3eee8116bf8d6a0eb4c4e5c69159360f1 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Fri, 15 Nov 2019 11:05:55 -0500 Subject: [PATCH 48/48] disable claim bot --- bot/modules/claimbot.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/bot/modules/claimbot.js b/bot/modules/claimbot.js index b48d063..e7d2cea 100644 --- a/bot/modules/claimbot.js +++ b/bot/modules/claimbot.js @@ -6,7 +6,6 @@ let config = require('config'); let channels = config.get('claimbot').channels; const Discord = require('discord.js'); const request = require('request'); -let lastProcessedBlock = 0; module.exports = { init: init @@ -22,24 +21,6 @@ function init(discordBot_) { discordBot.channels.get(channels[0]).send('activating claimbot'); } -function announceClaims() { - let currentBlock = lastProcessedBlock; - getClaimsForLastBlock() - .then(claims => { - claims.forEach(c => { - if (c.height <= lastProcessedBlock) return; - currentBlock = Math.max(currentBlock, c.height); - - //filter claims that we don't want to announce - if (c.bid_state === 'Expired' || c.bid_state === 'Spent') return; - - discordPost(embedFromClaim(c)); - }); - lastProcessedBlock = currentBlock; - }) - .catch(console.error); -} - /** * * @param {Object} claim