diff --git a/bot/modules/claimbot.js b/bot/modules/claimbot.js index b03364b..3ae8922 100644 --- a/bot/modules/claimbot.js +++ b/bot/modules/claimbot.js @@ -14,7 +14,7 @@ module.exports = { init: init }; -function init(discordBot_, mongodburl) { +function init(discordBot_) { if (lbry) { throw new Error("init was already called once"); } @@ -31,7 +31,7 @@ function init(discordBot_, mongodburl) { const bitcoin = require("bitcoin"); lbry = new bitcoin.Client(config.get("lbrycrd")); - console.log("Activating claimbot"); + console.log("Activating claimbot "); discordBot.channels.get(channels[0]).send("activating claimbot"); setInterval(function() { @@ -55,6 +55,7 @@ function announceNewClaims() { Promise.all([getLastBlock(), lbryCall("getinfo")]) .then(function([lastProcessedBlock, currentBlockInfo]) { const currentHeight = currentBlockInfo["blocks"]; + console.log(currentHeight); if (lastProcessedBlock === null) { console.log( "First run. Setting last processed block to " + @@ -70,7 +71,9 @@ function announceNewClaims() { const firstBlockToProcess = testBlock || lastProcessedBlock + 1, lastBlockToProcess = testBlock || currentHeight; - // console.log('Doing blocks ' + firstBlockToProcess + ' to ' + lastBlockToProcess); + console.log( + "Doing blocks " + firstBlockToProcess + " to " + lastBlockToProcess + ); return announceClaimsLoop( firstBlockToProcess, lastBlockToProcess, @@ -104,7 +107,8 @@ function announceClaimsLoop(block, lastBlock, currentHeight) { claims.map(function(claim) { //slack has a rate limit. to avoid hitting it we must have a small delay between each message //if claims were found in this block, then we wait, otherwise we don't - if (claimsFound > 0) sleep.msleep(300); + if (claimsFound > 0 && claim.hasOwnProperty("claimId")) + sleep.msleep(300); return announceClaim(claim, block, currentHeight); }) ); @@ -131,7 +135,7 @@ function announceClaim(claim, claimBlockHeight, currentHeight) { request(options, function(error, response, body) { if (error) throw new Error(error); try { - console.log(body); + console.log(JSON.stringify(JSON.parse(body), null, 2)); let claimData = null; let channelName = null; try { @@ -308,8 +312,12 @@ function setLastBlock(block) { function discordPost(text, params) { let richEmbeded = new Discord.RichEmbed(params); + channels.forEach(channel => { - discordBot.channels.get(channel).send("", richEmbeded); + discordBot.channels + .get(channel) + .send("", richEmbeded) + .catch(console.error); }); } diff --git a/yarn.lock b/yarn.lock index 69fe315..5781bb4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18,8 +18,8 @@ ajv@^4.9.1: json-stable-stringify "^1.0.1" ajv@^5.1.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.3.0.tgz#4414ff74a50879c208ee5fdc826e32c303549eda" + version "5.5.1" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.1.tgz#b38bb8876d9e86bee994956a04e721e88b248eb2" dependencies: co "^4.6.0" fast-deep-equal "^1.0.0" @@ -415,8 +415,8 @@ bcrypt-pbkdf@^1.0.0: tweetnacl "^0.14.3" binary-extensions@^1.0.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.10.0.tgz#9aeb9a6c5e88638aad171e167f5900abe24835d0" + version "1.11.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" bitcoin@^3.0.1: version "3.0.1" @@ -428,9 +428,9 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^3.5.0: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" +bluebird@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" boom@2.x.x: version "2.10.1" @@ -515,8 +515,8 @@ chrono-node@^1.3.5: moment "^2.10.3" ci-info@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.1.tgz#47b44df118c48d2597b56d342e7e25791060171a" + version "1.1.2" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.2.tgz#03561259db48d0474c8bdc90f5b47b068b6bbfb4" cjson@~0.2.1: version "0.2.1" @@ -551,16 +551,16 @@ commander@2.10.0: graceful-readlink ">= 1.0.0" commander@^2.11.0: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" + version "2.12.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" config@^1.27.0: - version "1.28.0" - resolved "https://registry.yarnpkg.com/config/-/config-1.28.0.tgz#666740053a81489905f26087c8656394c193507d" + version "1.28.1" + resolved "https://registry.yarnpkg.com/config/-/config-1.28.1.tgz#7625d2a1e4c90f131d8a73347982d93c3873282d" dependencies: json5 "0.4.0" os-homedir "1.0.2" @@ -570,8 +570,8 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" convert-source-map@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" + version "1.5.1" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" core-js@^2.4.0, core-js@^2.5.0: version "2.5.1" @@ -611,7 +611,7 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -debug@^2.1.2, debug@^2.2.0, debug@^2.6.8, debug@^2.6.9: +debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.6.8: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -636,8 +636,8 @@ detect-indent@^4.0.0: repeating "^2.0.0" detect-libc@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.2.tgz#71ad5d204bf17a6a6ca8f450c61454066ef461e1" + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" discord.js@11.1.0: version "11.1.0" @@ -685,8 +685,8 @@ elmadev-discord-irc@^2.4.1: winston "2.3.1" embed-creator@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/embed-creator/-/embed-creator-1.1.4.tgz#7f8a783db6ae384d029e746837d65553e6ff0f9e" + version "1.2.3" + resolved "https://registry.yarnpkg.com/embed-creator/-/embed-creator-1.2.3.tgz#f122165d39f9ca35aed3ef7b7ae643e7dd856ea1" es6-promise@3.2.1: version "3.2.1" @@ -756,10 +756,14 @@ extglob@^0.3.1: dependencies: is-extglob "^1.0.0" -extsprintf@1.3.0, extsprintf@^1.2.0: +extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + eyes@0.1.x: version "0.1.8" resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" @@ -817,19 +821,19 @@ form-data@~2.3.1: mime-types "^2.1.12" fs-readdir-recursive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + version "1.1.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" fsevents@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" + version "1.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.3.tgz#11f82318f5fe7bb2cd22965a108e9306208216d8" dependencies: nan "^2.3.0" - node-pre-gyp "^0.6.36" + node-pre-gyp "^0.6.39" fstream-ignore@^1.0.5: version "1.0.5" @@ -1022,8 +1026,8 @@ inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" ini@~1.3.0: - version "1.3.4" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" invariant@^2.2.2: version "2.2.2" @@ -1032,8 +1036,8 @@ invariant@^2.2.2: loose-envify "^1.0.0" irc-colors@^1.1.0, irc-colors@^1.3.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/irc-colors/-/irc-colors-1.4.0.tgz#6cb9f6ce6b14eacb7a6b7e516e7b95d773b8439b" + version "1.4.1" + resolved "https://registry.yarnpkg.com/irc-colors/-/irc-colors-1.4.1.tgz#ac8a3c8970f9be686fc6d678fd392af3d415fec0" irc-formatting@^1.0.0-rc3: version "1.0.0-rc3" @@ -1319,8 +1323,8 @@ minimist@~0.0.1: minimist "0.0.8" moment@^2.10.3, moment@^2.19.1: - version "2.19.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.19.1.tgz#56da1a2d1cbf01d38b7e1afc31c10bcfa1929167" + version "2.19.3" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.19.3.tgz#bdb99d270d6d7fda78cc0fbace855e27fe7da69f" mongodb-core@2.1.17: version "2.1.17" @@ -1338,8 +1342,8 @@ mongodb@2.2.33: readable-stream "2.2.7" mongoose@^4.12.3: - version "4.13.0" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.13.0.tgz#81bb266e045d66ac8dfdd84fc6749c873d7a6ac4" + version "4.13.6" + resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.13.6.tgz#48102f0b0d797a9bd273e581eef16d0505ef3d79" dependencies: async "2.1.4" bson "~1.0.4" @@ -1349,7 +1353,7 @@ mongoose@^4.12.3: mongodb "2.2.33" mpath "0.3.0" mpromise "0.5.5" - mquery "2.3.2" + mquery "2.3.3" ms "2.0.0" muri "1.3.0" regexp-clone "0.0.1" @@ -1363,13 +1367,13 @@ mpromise@0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/mpromise/-/mpromise-0.5.5.tgz#f5b24259d763acc2257b0a0c8c6d866fd51732e6" -mquery@2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-2.3.2.tgz#e2c60ad117cf080f2efb1ecdd144e7bbffbfca11" +mquery@2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/mquery/-/mquery-2.3.3.tgz#221412e5d4e7290ca5582dd16ea8f190a506b518" dependencies: - bluebird "^3.5.0" - debug "^2.6.9" - regexp-clone "^0.0.1" + bluebird "3.5.0" + debug "2.6.9" + regexp-clone "0.0.1" sliced "0.0.5" ms@2.0.0: @@ -1380,11 +1384,7 @@ muri@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/muri/-/muri-1.3.0.tgz#aeccf3db64c56aa7c5b34e00f95b7878527a4721" -nan@>=2.5.1, nan@^2.3.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46" - -nan@^2.3.3, nan@^2.3.5: +nan@>=2.5.1, nan@^2.3.0, nan@^2.3.3, nan@^2.3.5: version "2.8.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" @@ -1409,7 +1409,7 @@ node-icu-charset-detector@~0.2.0: dependencies: nan "^2.3.3" -node-pre-gyp@^0.6.36: +node-pre-gyp@^0.6.39: version "0.6.39" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" dependencies: @@ -1633,7 +1633,7 @@ regex-cache@^0.4.2: dependencies: is-equal-shallow "^0.1.3" -regexp-clone@0.0.1, regexp-clone@^0.0.1: +regexp-clone@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-0.0.1.tgz#a7c2e09891fdbf38fbb10d376fb73003e68ac589" @@ -1773,8 +1773,8 @@ sliced@1.0.1: resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" snekfetch@^3.1.0, snekfetch@^3.3.0: - version "3.5.8" - resolved "https://registry.yarnpkg.com/snekfetch/-/snekfetch-3.5.8.tgz#4d4e539f8435352105e74c392f62f66740a27d6c" + version "3.6.0" + resolved "https://registry.yarnpkg.com/snekfetch/-/snekfetch-3.6.0.tgz#f4f64064168d5b10aff7e9945d6d2932fda1aa54" sntp@1.x.x: version "1.0.9" @@ -1933,8 +1933,8 @@ uid-number@^0.0.6: resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" ultron@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.0.tgz#b07a2e6a541a815fc6a34ccd4533baec307ca864" + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" underscore@1.1.x: version "1.1.7" @@ -2009,8 +2009,8 @@ ws@^2.0.0: ultron "~1.1.0" ws@^3.1.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.1.tgz#d97e34dee06a1190c61ac1e95f43cb60b78cf939" + version "3.3.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.2.tgz#96c1d08b3fefda1d5c1e33700d3bfaa9be2d5608" dependencies: async-limiter "~1.0.0" safe-buffer "~5.1.0"