Merge branch 'master' into patch-8

This commit is contained in:
Ralph 2018-04-17 16:54:36 -04:00 committed by GitHub
commit 2e527ff3a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 3181 additions and 2239 deletions

15
LICENSE Normal file
View file

@ -0,0 +1,15 @@
The MIT License (MIT)
Copyright (c) 2016-2018 LBRY Inc
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -44,7 +44,9 @@ bot.on('ready', function() {
console.log('Logged in! Serving in ' + bot.guilds.array().length + ' servers');
require('./plugins.js').init();
console.log('type ' + config.prefix + 'help in Discord for a commands list.');
bot.user.setGame(config.prefix + 'help');
bot.user
.setActivity(config.prefix + 'help', { type: 'LISTENING' })
.catch(console.error);
//initialize the claimbot (content bot)
claimbot.init(bot);
@ -54,15 +56,39 @@ bot.on('ready', function() {
supportbot.init(bot);
});
process.on('unhandledRejection', err => {
console.log('unhandledRejection: ' + err);
process.exit(1); //exit node.js with an error
});
bot.on('disconnected', function() {
console.log('Disconnected!');
process.exit(1); //exit node.js with an error
});
bot.on('error', function(error) {
console.log('error: ' + error);
process.exit(1); //exit node.js with an error
});
function checkMessageForCommand(msg, isEdit) {
//check if message is a command
if (msg.author.id != bot.user.id && msg.content.startsWith(config.prefix)) {
console.log('treating ' + msg.content + ' from UserID:' + msg.author + ' || UserName: ' + msg.author.username + ' as command');
//check if user is Online
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(msg.author +
', Please enable Direct Messages from server members to communicate fully with our bot, ' +
'it is located in the user setting area under Privacy & Safety tab, ' +
'select the option allow direct messages from server members'
).then(msg.channel.send(
'Please set your Discord Presence to Online to talk to the Bot!'
)
);
return;
});
}
var cmdTxt = msg.content.split(' ')[0].substring(config.prefix.length);
var suffix = msg.content.substring(cmdTxt.length + config.prefix.length + 1); //add one for the ! and one for the space
if (msg.isMentioned(bot.user)) {
@ -77,6 +103,7 @@ function checkMessageForCommand(msg, isEdit) {
}
let cmd = aliases.hasOwnProperty(cmdTxt) ? commands[aliases[cmdTxt]] : commands[cmdTxt];
if (cmdTxt === 'help') {
//help is special since it iterates over the other commands
if (suffix) {
@ -135,6 +162,7 @@ function checkMessageForCommand(msg, isEdit) {
}
} else if (cmd) {
// Add permission check here later on ;)
console.log('treating ' + msg.content + ' from UserID:' + msg.author + ' || UserName: ' + msg.author.username + ' as command');
try {
cmd.process(bot, msg, suffix, isEdit);
} catch (e) {

View file

@ -1,89 +1,66 @@
let needle = require("needle");
let hasPriceBotChannels = require("../helpers.js").hasPriceBotChannels;
let inPrivate = require("../helpers.js").inPrivate;
let config = require("config");
let ChannelID = config.get("pricebot").mainchannel;
let needle = require('needle');
let hasPriceBotChannels = require('../helpers.js').hasPriceBotChannels;
let inPrivate = require('../helpers.js').inPrivate;
let config = require('config');
let ChannelID = config.get('pricebot').mainchannel;
exports.commands = ["altprice"];
exports.commands = ['altprice'];
exports.altprice = {
usage: "<coin> <fiat/coin> <amount>",
description:
"display price of specified alt coin from crypto compare\n**Example:** *!altprice ETH USD 100*",
usage: '<coin> <fiat/coin> <amount>',
description: 'display price of specified alt coin from crypto compare\n**Example:** *!altprice ETH USD 100*',
process: function(bot, msg, suffix) {
let dt = new Date();
let timestamp = dt.toUTCString();
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send(
"Please use <#" + ChannelID + "> or DMs to talk to price bot."
);
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
return;
}
if (suffix !== "") {
if (suffix !== '') {
words = suffix
.trim()
.split(" ")
.split(' ')
.filter(function(n) {
return n !== "";
return n !== '';
});
var currency1 = words[0].toUpperCase();
if (words[1] == undefined) {
var currency2 = "BTC";
var currency2 = 'BTC';
} else {
var currency2 = words[1].toUpperCase();
}
if (words[2] == undefined) {
var amount = "1";
var amount = '1';
} else {
if (getValidatedAmount(words[2]) === null) {
msg.reply("Please specify a number for <amount>");
msg.reply('Please specify a number for <amount>');
return;
}
var amount = words[2].toUpperCase();
}
} else {
var currency1 = "BTC";
var currency2 = "USD";
var amount = "1";
var currency1 = 'BTC';
var currency2 = 'USD';
var amount = '1';
}
needle.get("https://min-api.cryptocompare.com/data/all/coinlist", function(
error,
response
) {
needle.get('https://min-api.cryptocompare.com/data/all/coinlist', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available");
msg.channel.send('coinmarketcap API is not available');
} else {
if (!response.body.Data.hasOwnProperty(currency1)) {
msg.channel.send("Invalid Alt Coin");
msg.channel.send('Invalid Alt Coin');
return;
}
needle.get(
"https://min-api.cryptocompare.com/data/price?fsym=" +
currency1 +
"&tsyms=" +
currency2,
function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available");
} else {
var price = Number(response.body[currency2]);
var newprice = price * amount;
var message =
amount +
" " +
currency1 +
" = " +
newprice.toFixed(8) +
" " +
currency2 +
"\n" +
"*Updated: " +
timestamp +
"*";
msg.channel.send(message);
}
needle.get('https://min-api.cryptocompare.com/data/price?fsym=' + currency1 + '&tsyms=' + currency2, function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('coinmarketcap API is not available');
} else {
var price = Number(response.body[currency2]);
var newprice = price * amount;
var message = amount + ' ' + currency1 + ' = ' + newprice.toFixed(8) + ' ' + currency2 + '\n' + '*Updated: ' + timestamp + '*';
msg.channel.send(message);
}
);
});
}
});
function getValidatedAmount(amount) {

View file

@ -1,14 +1,14 @@
"use strict";
'use strict';
let lbry;
let mongo;
let discordBot;
let moment = require("moment");
let request = require("request");
let sleep = require("sleep");
let config = require("config");
let channels = config.get("claimbot").channels;
const Discord = require("discord.js");
let moment = require('moment');
let request = require('request');
let sleep = require('sleep');
let config = require('config');
let channels = config.get('claimbot').channels;
const Discord = require('discord.js');
module.exports = {
init: init
@ -16,23 +16,23 @@ module.exports = {
function init(discordBot_) {
if (lbry) {
throw new Error("init was already called once");
throw new Error('init was already called once');
}
discordBot = discordBot_;
const MongoClient = require("mongodb").MongoClient;
MongoClient.connect(config.get("mongodb").url, function(err, db) {
const MongoClient = require('mongodb').MongoClient;
MongoClient.connect(config.get('mongodb').url, function(err, db) {
if (err) {
throw err;
}
mongo = db;
const bitcoin = require("bitcoin");
lbry = new bitcoin.Client(config.get("lbrycrd"));
const bitcoin = require('bitcoin');
lbry = new bitcoin.Client(config.get('lbrycrd'));
console.log("Activating claimbot ");
discordBot.channels.get(channels[0]).send("activating claimbot");
console.log('Activating claimbot ');
discordBot.channels.get(channels[0]).send('activating claimbot');
setInterval(function() {
announceNewClaims();
@ -43,25 +43,21 @@ function init(discordBot_) {
function announceNewClaims() {
if (!mongo) {
discordPost("Failed to connect to mongo", {});
discordPost('Failed to connect to mongo', {});
return;
}
if (!lbry) {
discordPost("Failed to connect to lbrycrd", {});
discordPost('Failed to connect to lbrycrd', {});
return;
}
Promise.all([getLastBlock(), lbryCall("getinfo")])
Promise.all([getLastBlock(), lbryCall('getinfo')])
.then(function([lastProcessedBlock, currentBlockInfo]) {
const currentHeight = currentBlockInfo["blocks"];
const currentHeight = currentBlockInfo['blocks'];
console.log(currentHeight);
if (lastProcessedBlock === null) {
console.log(
"First run. Setting last processed block to " +
currentHeight +
" and exiting."
);
console.log('First run. Setting last processed block to ' + currentHeight + ' and exiting.');
return setLastBlock(currentHeight);
}
@ -71,14 +67,8 @@ function announceNewClaims() {
const firstBlockToProcess = testBlock || lastProcessedBlock + 1,
lastBlockToProcess = testBlock || currentHeight;
console.log(
"Doing blocks " + firstBlockToProcess + " to " + lastBlockToProcess
);
return announceClaimsLoop(
firstBlockToProcess,
lastBlockToProcess,
currentHeight
);
console.log('Doing blocks ' + firstBlockToProcess + ' to ' + lastBlockToProcess);
return announceClaimsLoop(firstBlockToProcess, lastBlockToProcess, currentHeight);
}
})
.catch(function(err) {
@ -88,27 +78,24 @@ function announceNewClaims() {
function announceClaimsLoop(block, lastBlock, currentHeight) {
let claimsFound = 0;
return lbryCall("getblockhash", block)
return lbryCall('getblockhash', block)
.then(function(blockHash) {
return lbryCall("getblock", blockHash);
return lbryCall('getblock', blockHash);
})
.then(function(blockData) {
return Promise.all(blockData["tx"].map(getClaimsForTxid));
return Promise.all(blockData['tx'].map(getClaimsForTxid));
})
.then(function(arrayOfClaimArrays) {
const claims = Array.prototype
.concat(...arrayOfClaimArrays)
.filter(function(c) {
return !!c;
});
console.log("Found " + claims.length + " claims in " + block);
const claims = Array.prototype.concat(...arrayOfClaimArrays).filter(function(c) {
return !!c;
});
console.log('Found ' + claims.length + ' claims in ' + block);
claimsFound = claims.length;
return Promise.all(
claims.map(function(claim) {
//the API 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 && claim.hasOwnProperty("claimId"))
sleep.msleep(300);
if (claimsFound > 0 && claim.hasOwnProperty('claimId')) sleep.msleep(300);
return announceClaim(claim, block, currentHeight);
})
);
@ -125,17 +112,17 @@ function announceClaimsLoop(block, lastBlock, currentHeight) {
}
function announceClaim(claim, claimBlockHeight, currentHeight) {
console.log("" + claimBlockHeight + ": New claim for " + claim["name"]);
console.log('' + claimBlockHeight + ': New claim for ' + claim['name']);
console.log(claim);
//ignore supports for now
//the issue with supports is that they should be treated completely differently
//they are not new claims...
if (claim.hasOwnProperty("supported claimId")) return;
if (claim.hasOwnProperty('supported claimId')) return;
let options = {
method: "GET",
url: "http://127.0.0.1:5000/claim_decode/" + claim["name"]
method: 'GET',
url: 'http://127.0.0.1:5000/claim_decode/' + claim['name']
};
request(options, function(error, response, body) {
@ -146,30 +133,22 @@ function announceClaim(claim, claimBlockHeight, currentHeight) {
let channelName = null;
try {
body = JSON.parse(body);
if (
body.hasOwnProperty("stream") &&
body.stream.hasOwnProperty("metadata")
) {
if (body.hasOwnProperty('stream') && body.stream.hasOwnProperty('metadata')) {
claimData = body.stream.metadata;
channelName = body.hasOwnProperty("channel_name")
? body["channel_name"]
: null;
channelName = body.hasOwnProperty('channel_name') ? body['channel_name'] : null;
}
} catch (e) {
console.error(e);
return;
}
return Promise.all([
lbryCall("getvalueforname", claim["name"]),
lbryCall("getclaimsforname", claim["name"])
]).then(function([currentWinningClaim, claimsForName]) {
return Promise.all([lbryCall('getvalueforname', claim['name']), lbryCall('getclaimsforname', claim['name'])]).then(function([currentWinningClaim, claimsForName]) {
//console.log(JSON.stringify(claimData));
let value = null;
if (claimData !== null) value = claimData;
else {
try {
value = JSON.parse(claim["value"]);
value = JSON.parse(claim['value']);
} catch (e) {}
}
@ -183,74 +162,52 @@ function announceClaim(claim, claimBlockHeight, currentHeight) {
else
*/
console.log(value);
if (value["author"]) {
text.push("author: " + value["author"]);
if (value['author']) {
text.push('author: ' + value['author']);
}
if (value["description"]) {
text.push(value["description"]);
if (value['description']) {
text.push(value['description']);
}
// if (value['content_type'])
// {
// text.push("*Content Type:* " + value['content_type']);
// }
if (value["nsfw"]) {
text.push("*Warning: Adult Content*");
if (value['nsfw']) {
text.push('*Warning: Adult Content*');
}
//"fee":{"currency":"LBC","amount":186,"version":"_0_0_1","address":"bTGoFCakvQXvBrJg1b7FJzombFUu6iRJsk"}
if (value["fee"]) {
if (value['fee']) {
const fees = [];
text.push(
"Price: " +
value["fee"].amount +
" *" +
value["fee"].currency +
"*"
);
text.push('Price: ' + value['fee'].amount + ' *' + value['fee'].currency + '*');
}
if (!claim["is controlling"]) {
if (!claim['is controlling']) {
// the following is based on https://lbry.io/faq/claimtrie-implementation
const lastTakeoverHeight = claimsForName["nLastTakeoverHeight"],
const lastTakeoverHeight = claimsForName['nLastTakeoverHeight'],
maxDelay = 4032, // 7 days of blocks at 2.5min per block
activationDelay = Math.min(
maxDelay,
Math.floor((claimBlockHeight - lastTakeoverHeight) / 32)
),
activationDelay = Math.min(maxDelay, Math.floor((claimBlockHeight - lastTakeoverHeight) / 32)),
takeoverHeight = claimBlockHeight + activationDelay,
secondsPerBlock = 161, // in theory this should be 150, but in practice its closer to 161
takeoverTime =
Date.now() +
(takeoverHeight - currentHeight) * secondsPerBlock * 1000;
takeoverTime = Date.now() + (takeoverHeight - currentHeight) * secondsPerBlock * 1000;
text.push(
"Takes effect on approx. **" +
moment(takeoverTime, "x").format("MMMM Do [at] HH:mm [UTC]") +
"** (block " +
takeoverHeight +
")"
);
text.push('Takes effect on approx. **' + moment(takeoverTime, 'x').format('MMMM Do [at] HH:mm [UTC]') + '** (block ' + takeoverHeight + ')');
}
const richEmbeded = {
author: {
name: value["author"] || "Anonymous",
url: "http://open.lbry.io/" + claim["name"],
icon_url:
"http://barkpost-assets.s3.amazonaws.com/wp-content/uploads/2013/11/3dDoge.gif"
name: value['author'] || 'Anonymous',
url: 'http://open.lbry.io/' + claim['name'],
icon_url: 'http://barkpost-assets.s3.amazonaws.com/wp-content/uploads/2013/11/3dDoge.gif'
},
title:
"lbry://" +
(channelName ? channelName + "/" : "") +
claim["name"],
title: 'lbry://' + (channelName ? channelName + '/' : '') + claim['name'],
color: 1399626,
description: escapeSlackHtml(text.join("\n")),
description: escapeSlackHtml(text.join('\n')),
footer: {
text:
"Block " + claimBlockHeight + " • Claim ID " + claim["claimId"]
text: 'Block ' + claimBlockHeight + ' • Claim ID ' + claim['claimId']
},
image: { url: !value["nsfw"] ? value["thumbnail"] || "" : "" },
url: "http://open.lbry.io/" + claim["name"]
image: { url: !value['nsfw'] ? value['thumbnail'] || '' : '' },
url: 'http://open.lbry.io/' + claim['name']
};
discordPost(text, richEmbeded);
@ -264,13 +221,13 @@ function announceClaim(claim, claimBlockHeight, currentHeight) {
function escapeSlackHtml(txt) {
return txt
.replace("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;");
.replace('&', '&amp;')
.replace('<', '&lt;')
.replace('>', '&gt;');
}
function getClaimsForTxid(txid) {
return lbryCall("getclaimsfortx", txid).catch(function(err) {
return lbryCall('getclaimsfortx', txid).catch(function(err) {
// an error here most likely means the transaction is spent,
// which also means there are no claims worth looking at
return [];
@ -279,13 +236,11 @@ function getClaimsForTxid(txid) {
function getLastBlock() {
return new Promise(function(resolve, reject) {
mongo.collection("claimbot").findOne({}, function(err, obj) {
mongo.collection('claimbot').findOne({}, function(err, obj) {
if (err) {
reject(err);
} else if (!obj) {
mongo
.collection("claimbot")
.createIndex({ last_block: 1 }, { unique: true });
mongo.collection('claimbot').createIndex({ last_block: 1 }, { unique: true });
resolve(null);
} else {
resolve(obj.last_block);
@ -296,25 +251,13 @@ function getLastBlock() {
function setLastBlock(block) {
return new Promise(function(resolve, reject) {
mongo
.collection("claimbot")
.findOneAndUpdate(
{ last_block: { $exists: true } },
{ last_block: block },
{ upsert: true, returnOriginal: false },
function(err, obj) {
if (!err && obj && obj.value.last_block != block) {
reject(
"Last value should be " +
block +
", but it is " +
obj.value.last_block
);
} else {
resolve();
}
}
);
mongo.collection('claimbot').findOneAndUpdate({ last_block: { $exists: true } }, { last_block: block }, { upsert: true, returnOriginal: false }, function(err, obj) {
if (!err && obj && obj.value.last_block != block) {
reject('Last value should be ' + block + ', but it is ' + obj.value.last_block);
} else {
resolve();
}
});
});
}
@ -324,7 +267,7 @@ function discordPost(text, params) {
channels.forEach(channel => {
discordBot.channels
.get(channel)
.send("", richEmbeded)
.send('', richEmbeded)
.catch(console.error);
});
}
@ -333,9 +276,7 @@ function lbryCall(...args) {
return new Promise(function(resolve, reject) {
lbry.cmd(...args, function(err, ...response) {
if (err) {
reject(
new Error("JSONRPC call failed. Args: [" + args.join(", ") + "]")
);
reject(new Error('JSONRPC call failed. Args: [' + args.join(', ') + ']'));
} else {
resolve(...response);
}

View file

@ -1,6 +1,6 @@
"use strict";
let commands = require("../../config/commands");
const Discord = require("discord.js");
'use strict';
let commands = require('../../config/commands');
const Discord = require('discord.js');
let initialized = false;
let discordBot = null;
let commandsList = null;
@ -11,12 +11,12 @@ module.exports = {
function init(discordBot_) {
if (initialized) {
throw new Error("init was already called once");
throw new Error('init was already called once');
}
discordBot = discordBot_;
discordBot.on("message", checkForCommand);
discordBot.on('message', checkForCommand);
}
/**
@ -28,31 +28,24 @@ let checkForCommand = function(message) {
let firstRun = false;
if (commandsList === null) {
firstRun = true;
commandsList = "";
commandsList = '';
}
//for each message go through all the commands and check if there are any matches
Object.keys(commands).forEach(command => {
//during the first run also build the cache
if (firstRun) commandsList += command + ", ";
if (firstRun) commandsList += command + ', ';
//if a command is found
if (
!message.author.bot &&
message.content.toLowerCase().indexOf(command.toLowerCase()) >= 0 &&
commands[command].operation === "send"
) {
if (!message.author.bot && message.content.toLowerCase().indexOf(command.toLowerCase()) >= 0 && commands[command].operation === 'send') {
//send a message to the channel according to the config
message.channel.send("", new Discord.RichEmbed(commands[command].bundle));
message.channel.send('', new Discord.RichEmbed(commands[command].bundle));
}
});
//if the user is requesting the list of commands, then print it
if (
!message.author.bot &&
message.content.toLowerCase().indexOf("!helpcommands") >= 0
) {
let bundle = commands["!helpcommands"].bundle;
commandsList = commandsList.replace(/,\s$/g, "");
bundle.description = "**" + commandsList + "**";
message.channel.send("", new Discord.RichEmbed(bundle));
if (!message.author.bot && message.content.toLowerCase().indexOf('!helpcommands') >= 0) {
let bundle = commands['!helpcommands'].bundle;
commandsList = commandsList.replace(/,\s$/g, '');
bundle.description = '**' + commandsList + '**';
message.channel.send('', new Discord.RichEmbed(bundle));
}
};

View file

@ -1,13 +1,13 @@
let needle = require("needle");
let config = require("config");
let hasHashBotChannels = require("../helpers.js").hasHashBotChannels;
let inPrivate = require("../helpers.js").inPrivate;
let ChannelID = config.get("hashbot").mainchannel;
let needle = require('needle');
let config = require('config');
let hasHashBotChannels = require('../helpers.js').hasHashBotChannels;
let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get('hashbot').mainchannel;
exports.commands = [
"hash" // command that is in this file, every command needs it own export as shown below
'hash' // command that is in this file, every command needs it own export as shown below
];
exports.custom = ["timedhash"];
exports.custom = ['timedhash'];
exports.timedhash = function(bot) {
setInterval(function() {
@ -15,55 +15,49 @@ exports.timedhash = function(bot) {
}, 6 * 60 * 60 * 1000);
function sendMiningInfo(bot) {
needle.get("https://explorer.lbry.io/api/v1/status", function(
error,
response
) {
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("Explorer API is not available");
msg.channel.send('Explorer API is not available');
} else {
var data = response.body;
var height = Number(data.status.height);
var hashrate = data.status.hashrate;
var difficulty = Number(data.status.difficulty);
needle.get("https://whattomine.com/coins/164.json", function(
error,
response
) {
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("whattomine API is not available");
msg.channel.send('whattomine API is not available');
}
var data = response.body;
var reward = Number(data.block_reward);
var block_time = Number(data.block_time);
var difficulty24 = Number(data.difficulty24);
description =
"Hashrate: " +
'Hashrate: ' +
numberWithCommas(hashrate) +
"\n" +
"Difficulty: " +
'\n' +
'Difficulty: ' +
numberWithCommas(difficulty.toFixed(0)) +
"\n" +
"Difficulty 24 Hour Average: " +
'\n' +
'Difficulty 24 Hour Average: ' +
numberWithCommas(difficulty24.toFixed(0)) +
"\n" +
"Current block: " +
'\n' +
'Current block: ' +
numberWithCommas(height.toFixed(0)) +
"\n" +
"Block Time: " +
'\n' +
'Block Time: ' +
numberWithCommas(block_time.toFixed(0)) +
" seconds \n" +
"Block Reward: " +
' seconds \n' +
'Block Reward: ' +
numberWithCommas(reward.toFixed(0)) +
" LBC \n" +
"Sources: https://explorer.lbry.io & \n" +
"https://whattomine.com/coins/164-lbc-lbry";
' LBC \n' +
'Sources: https://explorer.lbry.io & \n' +
'https://whattomine.com/coins/164-lbc-lbry';
const embed = {
description: description,
color: 7976557,
author: {
name: "LBRY Network Stats",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'LBRY Network Stats',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
};
bot.channels.get(ChannelID).send({ embed });
@ -72,26 +66,25 @@ exports.timedhash = function(bot) {
}
});
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};
exports.hash = {
usage: "",
description:
"Displays current Hashrate of Network\n**!hash power <Mh/s>**\n Displays potential Earnings For Given Hashrate",
usage: '',
description: 'Displays current Hashrate of Network\n**!hash power <Mh/s>**\n Displays potential Earnings For Given Hashrate',
process: function(bot, msg, suffix) {
var command = "!hash";
var command = '!hash';
words = suffix
.trim()
.split(" ")
.split(' ')
.filter(function(n) {
return n !== "";
return n !== '';
});
profitcommand = words[0];
myhashrate = words[1];
if (profitcommand == "power") {
if (profitcommand == 'power') {
sendProfitInfo(bot, msg, suffix);
return;
} else {
@ -101,60 +94,52 @@ exports.hash = {
function sendMiningInfo(bot, msg, suffix) {
if (!inPrivate(msg) && !hasHashBotChannels(msg)) {
msg.channel.send(
"Please use <#" + ChannelID + "> or DMs to talk to hash bot."
);
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to hash bot.');
return;
}
needle.get("https://explorer.lbry.io/api/v1/status", function(
error,
response
) {
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("Explorer API is not available");
msg.channel.send('Explorer API is not available');
} else {
var data = response.body;
var height = Number(data.status.height);
var hashrate = data.status.hashrate;
var difficulty = Number(data.status.difficulty);
needle.get("https://whattomine.com/coins/164.json", function(
error,
response
) {
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("whattomine API is not available");
msg.channel.send('whattomine API is not available');
}
var data = response.body;
var reward = Number(data.block_reward);
var block_time = Number(data.block_time);
var difficulty24 = Number(data.difficulty24);
description =
"Hashrate: " +
'Hashrate: ' +
numberWithCommas(hashrate) +
"\n" +
"Difficulty: " +
'\n' +
'Difficulty: ' +
numberWithCommas(difficulty.toFixed(0)) +
"\n" +
"Difficulty 24 Hour Average: " +
'\n' +
'Difficulty 24 Hour Average: ' +
numberWithCommas(difficulty24.toFixed(0)) +
"\n" +
"Current block: " +
'\n' +
'Current block: ' +
numberWithCommas(height.toFixed(0)) +
"\n" +
"Block Time: " +
'\n' +
'Block Time: ' +
numberWithCommas(block_time.toFixed(0)) +
" seconds \n" +
"Block Reward: " +
' seconds \n' +
'Block Reward: ' +
numberWithCommas(reward.toFixed(0)) +
" LBC \n" +
"Sources: https://explorer.lbry.io & \n" +
"https://whattomine.com/coins/164-lbc-lbry";
' LBC \n' +
'Sources: https://explorer.lbry.io & \n' +
'https://whattomine.com/coins/164-lbc-lbry';
const embed = {
description: description,
color: 7976557,
author: {
name: "LBRY Network Stats",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'LBRY Network Stats',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
};
msg.channel.send({ embed });
@ -164,27 +149,19 @@ exports.hash = {
});
}
function sendProfitInfo(bot, msg, suffix) {
needle.get("https://whattomine.com/coins/164.json", function(
error,
response
) {
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("whattomine API is not available");
msg.channel.send('whattomine API is not available');
} else {
words = suffix
.trim()
.split(" ")
.split(' ')
.filter(function(n) {
return n !== "";
return n !== '';
});
var myhashrate = words[1];
if (
myhashrate == "" ||
myhashrate == null ||
myhashrate == undefined ||
myhashrate == " "
) {
myhashrate = "100";
if (myhashrate == '' || myhashrate == null || myhashrate == undefined || myhashrate == ' ') {
myhashrate = '100';
}
var Diff = response.body.difficulty24;
var Reward = response.body.block_reward;
@ -192,33 +169,32 @@ exports.hash = {
var LBC = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 3600;
var LBC24 = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 86400;
var LBC1w = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 604800;
var LBC1m =
myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 2628000;
var LBC1m = myHash / 2000 * (1 / ((Diff * 2) ^ 32) * Reward) * 2628000;
var message =
"With **" +
'With **' +
myHash +
" Mh/s** and Average 24 hour Difficulty: **" +
' Mh/s** and Average 24 hour Difficulty: **' +
Diff.toFixed(0) +
"**\n" +
"You can potentially earn the following amounts of **LBC**: \n" +
"1 Hour = **" +
'**\n' +
'You can potentially earn the following amounts of **LBC**: \n' +
'1 Hour = **' +
LBC.toFixed(4) +
"** \n" +
"1 Day = **" +
'** \n' +
'1 Day = **' +
LBC24.toFixed(2) +
"** \n" +
"1 Week = **" +
'** \n' +
'1 Week = **' +
LBC1w.toFixed(4) +
"** \n" +
"1 Month = **" +
'** \n' +
'1 Month = **' +
LBC1m.toFixed(4) +
"** \n";
'** \n';
const embed = {
description: message,
color: 7976557,
author: {
name: "Hashing Power Calculator!",
icon_url: "https://i.imgur.com/nKHVQgq.png"
name: 'Hashing Power Calculator!',
icon_url: 'https://i.imgur.com/nKHVQgq.png'
}
};
msg.channel.send({ embed });
@ -227,7 +203,7 @@ exports.hash = {
});
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};

View file

@ -1,7 +1,7 @@
const discordIRC = require("elmadev-discord-irc").default;
const config = require("config");
const ircconfig = config.get("irc");
exports.custom = ["irc"];
const discordIRC = require('elmadev-discord-irc').default;
const config = require('config');
const ircconfig = config.get('irc');
exports.custom = ['irc'];
exports.irc = function(bot) {
discordIRC([ircconfig]);

View file

@ -1,67 +1,88 @@
let inPrivate = require("../helpers.js").inPrivate;
let ResponseDebug = "false";
let inPrivate = require('../helpers.js').inPrivate;
let responseDebug = false;
exports.custom = [
"lbrylink" //change this to your function name
'lbrylink' //change this to your function name
];
exports.lbrylink = function(bot, msg, suffix) {
bot.on("message", msg => {
bot.on('message', msg => {
if (inPrivate(msg)) {
return;
}
var link = msg.content.indexOf("lbry://");
if (link != -1) {
var text = msg.content.replace("lbry://", "https://open.lbry.io/");
var message = GetWordByPos(text, link);
if (ResponseDebug == "true") {
console.log("text = " + text);
console.log("message = " + message);
if (msg.content.includes('lbry://')) {
//Extract URL from Message
newURL = msg.content
.replace('lbry://', 'https://open.lbry.io/')
.match(/\bhttps?:\/\/\S+/gi)
.toString();
if (responseDebug) {
console.log('___________________________');
console.log('newURL = ' + newURL);
}
if (message === "https://open.lbry.io/") {
//Check if just lbry:// was supplied
if (newURL == 'https://open.lbry.io/') {
return;
}
if (message.search(">") != -1) {
parsename = message.split(">").pop();
if (parsename.search("/") == -1) {
//Check if Username Was Supplied
if (newURL.includes('>')) {
//Get rid of ID from message
parseID = newURL.split('>').pop();
newURL = 'https://open.lbry.io' + parseID;
if (responseDebug) {
console.log('Username Provided!');
console.log('parseID = ' + parseID);
console.log('newURL = ' + newURL);
}
//check if just Username Was Supplied
if (!newURL.substr(20).includes('/')) {
return;
}
newname = message.split("/").pop();
message = "https://open.lbry.io/" + newname;
if (ResponseDebug == "true") {
console.log("Username Provided!");
console.log("parsename = " + parsename);
console.log("newname = " + newname);
//check if more than username was supplied
//Also check obscurity in username like ``@MSFTserver` vs `@MSFTserverPics`
if (parseID.includes('/')) {
//parse out extra params before `/` like `<@123456789>Pics`
parseID = parseID.split('/').pop();
newURL = 'https://open.lbry.io/' + parseID;
if (responseDebug) {
console.log('Username no / check');
console.log('parseID = ' + parseID);
console.log('newURL = ' + newURL);
}
//checks if username had if after it or just blank to be safe
if (newURL == 'https://open.lbry.io/' || parseID.startsWith('#')) {
return;
}
}
//one last saftey check
if (newURL == 'https://open.lbry.io') {
return;
}
//If no UserName Found proceed
} else {
var newname = message.replace("https://open.lbry.io/", "");
if (newURL == 'https://open.lbry.io/') {
return;
}
if (responseDebug) {
console.log('___________________________');
console.log('newURL = ' + newURL);
}
}
const embed = {
description:
"I see you tried to post a LBRY URL, here's a friendly hyperlink to share and for others to access your content with a single click: \n" +
"[lbry://" +
newname +
"](" +
message +
")",
description: "I see you tried to post a LBRY URL, here's a friendly hyperlink to share and for others to access your content with a single click: \n" + newURL,
color: 7976557,
author: {
name: "LBRY Linker",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'LBRY Linker',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
};
msg.channel.send({
embed
});
}
function GetWordByPos(str, pos) {
var left = str.substr(0, pos);
var right = str.substr(pos);
left = left.replace(/^.+ /g, "");
right = right.replace(/ .+$/g, "");
return left + right;
msg.channel.send({ embed });
}
});
};

View file

@ -1,268 +1,265 @@
"use strict";
let jp = require("jsonpath");
let moment = require("moment");
let numeral = require("numeral");
let request = require("request");
let config = require("config");
let hasPriceBotChannels = require("../helpers.js").hasPriceBotChannels;
let inPrivate = require("../helpers.js").inPrivate;
let ChannelID = config.get("pricebot").mainchannel;
'use strict';
let jp = require('jsonpath');
let moment = require('moment');
let numeral = require('numeral');
let request = require('request');
let config = require('config');
let hasPriceBotChannels = require('../helpers.js').hasPriceBotChannels;
let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get('pricebot').mainchannel;
exports.commands = ["price"];
exports.commands = ['price'];
exports.price = {
usage: "<currency> <amount>",
description: "displays price of lbc",
usage: '<currency> <amount>',
description: 'displays price of lbc',
process: function(bot, msg, suffix) {
var options = {
defaultCurrency: "BTC",
defaultCurrency: 'BTC',
// supported currencies and api steps to arrive at the final value
currencies: {
USD: {
steps: ["LBCBTC", "BTCUSD"],
format: "$0,0.00",
sign: "USD "
steps: ['LBCBTC', 'BTCUSD'],
format: '$0,0.00',
sign: 'USD '
},
GBP: {
steps: ["LBCBTC", "BTCGBP"],
format: "£0,0.00",
sign: "£"
steps: ['LBCBTC', 'BTCGBP'],
format: '£0,0.00',
sign: '£'
},
AUD: {
steps: ["LBCBTC", "BTCAUD"],
format: "$0,0.00",
sign: "AUD "
steps: ['LBCBTC', 'BTCAUD'],
format: '$0,0.00',
sign: 'AUD '
},
BRL: {
steps: ["LBCBTC", "BTCBRL"],
format: "R$0,0.00",
sign: "R$"
steps: ['LBCBTC', 'BTCBRL'],
format: 'R$0,0.00',
sign: 'R$'
},
CAD: {
steps: ["LBCBTC", "BTCCAD"],
format: "$0,0.00",
sign: "CAD "
steps: ['LBCBTC', 'BTCCAD'],
format: '$0,0.00',
sign: 'CAD '
},
CHF: {
steps: ["LBCBTC", "BTCCHF"],
format: "CHF 0,0.00",
sign: "CHF"
steps: ['LBCBTC', 'BTCCHF'],
format: 'CHF 0,0.00',
sign: 'CHF'
},
CLP: {
steps: ["LBCBTC", "BTCCLP"],
format: "$0,0.00",
sign: "CLP "
steps: ['LBCBTC', 'BTCCLP'],
format: '$0,0.00',
sign: 'CLP '
},
CNY: {
steps: ["LBCBTC", "BTCCNY"],
format: "¥0,0.00",
sign: "¥"
steps: ['LBCBTC', 'BTCCNY'],
format: '¥0,0.00',
sign: '¥'
},
DKK: {
steps: ["LBCBTC", "BTCDKK"],
format: "kr 0,0.00",
sign: "kr"
steps: ['LBCBTC', 'BTCDKK'],
format: 'kr 0,0.00',
sign: 'kr'
},
EUR: {
steps: ["LBCBTC", "BTCEUR"],
format: "€0,0.00",
sign: "€"
steps: ['LBCBTC', 'BTCEUR'],
format: '€0,0.00',
sign: '€'
},
HKD: {
steps: ["LBCBTC", "BTCHKD"],
format: "$0,0.00",
sign: "HKD "
steps: ['LBCBTC', 'BTCHKD'],
format: '$0,0.00',
sign: 'HKD '
},
INR: {
steps: ["LBCBTC", "BTCINR"],
format: "₹0,0.00",
sign: "₹"
steps: ['LBCBTC', 'BTCINR'],
format: '₹0,0.00',
sign: '₹'
},
ISK: {
steps: ["LBCBTC", "BTCISK"],
format: "kr 0,0.00",
sign: "kr"
steps: ['LBCBTC', 'BTCISK'],
format: 'kr 0,0.00',
sign: 'kr'
},
JPY: {
steps: ["LBCBTC", "BTCJPY"],
format: "¥0,0.00",
sign: "¥"
steps: ['LBCBTC', 'BTCJPY'],
format: '¥0,0.00',
sign: '¥'
},
KRW: {
steps: ["LBCBTC", "BTCKRW"],
format: "₩0,0.00",
sign: "₩"
steps: ['LBCBTC', 'BTCKRW'],
format: '₩0,0.00',
sign: '₩'
},
NZD: {
steps: ["LBCBTC", "BTCNZD"],
format: "$0,0.00",
sign: "NZD "
steps: ['LBCBTC', 'BTCNZD'],
format: '$0,0.00',
sign: 'NZD '
},
PLN: {
steps: ["LBCBTC", "BTCPLN"],
format: "zł 0,0.00",
sign: "zł"
steps: ['LBCBTC', 'BTCPLN'],
format: 'zł 0,0.00',
sign: 'zł'
},
RUB: {
steps: ["LBCBTC", "BTCRUB"],
format: "RUB 0,0.00",
sign: "RUB"
steps: ['LBCBTC', 'BTCRUB'],
format: 'RUB 0,0.00',
sign: 'RUB'
},
SEK: {
steps: ["LBCBTC", "BTCSEK"],
format: "kr 0,0.00",
sign: "kr"
steps: ['LBCBTC', 'BTCSEK'],
format: 'kr 0,0.00',
sign: 'kr'
},
SGD: {
steps: ["LBCBTC", "BTCSGD"],
format: "$0,0.00",
sign: "SGD "
steps: ['LBCBTC', 'BTCSGD'],
format: '$0,0.00',
sign: 'SGD '
},
THB: {
steps: ["LBCBTC", "BTCTHB"],
format: "฿0,0.00",
sign: "฿"
steps: ['LBCBTC', 'BTCTHB'],
format: '฿0,0.00',
sign: '฿'
},
TWD: {
steps: ["LBCBTC", "BTCTWD"],
format: "NT$0,0.00",
sign: "NT$"
steps: ['LBCBTC', 'BTCTWD'],
format: 'NT$0,0.00',
sign: 'NT$'
},
IDR: {
steps: ["LBCBTC", "BTCIDR"],
format: "Rp0,0.00",
sign: "Rp"
steps: ['LBCBTC', 'BTCIDR'],
format: 'Rp0,0.00',
sign: 'Rp'
},
BTC: {
steps: ["LBCBTC"],
format: "0,0[.][00000000] BTC",
sign: "BTC"
steps: ['LBCBTC'],
format: '0,0[.][00000000] BTC',
sign: 'BTC'
}
},
// api steps
api: {
LBCBTC: {
url: "https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC",
path: "$.result.Bid"
url: 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LBC',
path: '$.result.Bid'
},
BTCUSD: {
url: "https://blockchain.info/ticker",
path: "$.USD.buy"
url: 'https://blockchain.info/ticker',
path: '$.USD.buy'
},
BTCGBP: {
url: "https://blockchain.info/ticker",
path: "$.GBP.buy"
url: 'https://blockchain.info/ticker',
path: '$.GBP.buy'
},
BTCAUD: {
url: "https://blockchain.info/ticker",
path: "$.AUD.buy"
url: 'https://blockchain.info/ticker',
path: '$.AUD.buy'
},
BTCBRL: {
url: "https://blockchain.info/ticker",
path: "$.BRL.buy"
url: 'https://blockchain.info/ticker',
path: '$.BRL.buy'
},
BTCCAD: {
url: "https://blockchain.info/ticker",
path: "$.CAD.buy"
url: 'https://blockchain.info/ticker',
path: '$.CAD.buy'
},
BTCCHF: {
url: "https://blockchain.info/ticker",
path: "$.CHF.buy"
url: 'https://blockchain.info/ticker',
path: '$.CHF.buy'
},
BTCCLP: {
url: "https://blockchain.info/ticker",
path: "$.CLP.buy"
url: 'https://blockchain.info/ticker',
path: '$.CLP.buy'
},
BTCCNY: {
url: "https://blockchain.info/ticker",
path: "$.CNY.buy"
url: 'https://blockchain.info/ticker',
path: '$.CNY.buy'
},
BTCDKK: {
url: "https://blockchain.info/ticker",
path: "$.DKK.buy"
url: 'https://blockchain.info/ticker',
path: '$.DKK.buy'
},
BTCEUR: {
url: "https://blockchain.info/ticker",
path: "$.EUR.buy"
url: 'https://blockchain.info/ticker',
path: '$.EUR.buy'
},
BTCHKD: {
url: "https://blockchain.info/ticker",
path: "$.HKD.buy"
url: 'https://blockchain.info/ticker',
path: '$.HKD.buy'
},
BTCINR: {
url: "https://blockchain.info/ticker",
path: "$.INR.buy"
url: 'https://blockchain.info/ticker',
path: '$.INR.buy'
},
BTCISK: {
url: "https://blockchain.info/ticker",
path: "$.ISK.buy"
url: 'https://blockchain.info/ticker',
path: '$.ISK.buy'
},
BTCJPY: {
url: "https://blockchain.info/ticker",
path: "$.JPY.buy"
url: 'https://blockchain.info/ticker',
path: '$.JPY.buy'
},
BTCKRW: {
url: "https://blockchain.info/ticker",
path: "$.KRW.buy"
url: 'https://blockchain.info/ticker',
path: '$.KRW.buy'
},
BTCNZD: {
url: "https://blockchain.info/ticker",
path: "$.NZD.buy"
url: 'https://blockchain.info/ticker',
path: '$.NZD.buy'
},
BTCPLN: {
url: "https://blockchain.info/ticker",
path: "$.PLN.buy"
url: 'https://blockchain.info/ticker',
path: '$.PLN.buy'
},
BTCRUB: {
url: "https://blockchain.info/ticker",
path: "$.RUB.buy"
url: 'https://blockchain.info/ticker',
path: '$.RUB.buy'
},
BTCSEK: {
url: "https://blockchain.info/ticker",
path: "$.SEK.buy"
url: 'https://blockchain.info/ticker',
path: '$.SEK.buy'
},
BTCSGD: {
url: "https://blockchain.info/ticker",
path: "$.SGD.buy"
url: 'https://blockchain.info/ticker',
path: '$.SGD.buy'
},
BTCTHB: {
url: "https://blockchain.info/ticker",
path: "$.THB.buy"
url: 'https://blockchain.info/ticker',
path: '$.THB.buy'
},
BTCTWD: {
url: "https://blockchain.info/ticker",
path: "$.TWD.buy"
url: 'https://blockchain.info/ticker',
path: '$.TWD.buy'
},
BTCIDR: {
url:
"https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=IDR",
path: "$.IDR"
url: 'https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=IDR',
path: '$.IDR'
}
},
// display date/time format
dtFormat: "Do MMM YYYY h:mma [UTC]",
dtFormat: 'Do MMM YYYY h:mma [UTC]',
// refresh rate in milliseconds to retrieve a new price (default to 10 minutes)
refreshTime: 100000
};
var words = suffix
.trim()
.split(" ")
.split(' ')
.filter(function(n) {
return n !== "";
return n !== '';
});
var currency =
words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency;
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;
var showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1;
// store the last retrieved rate
var cachedRates = {};
var command = "!price";
var command = '!price';
var currencies = Object.keys(options.currencies);
for (var i = 0; i < currencies.length; i++) {
@ -275,9 +272,7 @@ exports.price = {
doHelp(bot, msg, suffix);
} else {
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send(
"Please use <#" + ChannelID + "> or DMs to talk to price bot."
);
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
return;
}
doSteps(bot, currency, amount);
@ -285,44 +280,32 @@ exports.price = {
function doHelp(bot, msg, suffix) {
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send(
"Please use <#" + ChannelID + "> or DMs to talk to price bot."
);
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
return;
}
var message =
"**" +
'**' +
command +
"**: show the price of 1 LBC in " +
'**: show the price of 1 LBC in ' +
options.defaultCurrency +
"\n" +
"**" +
'\n' +
'**' +
command +
" help**: this message\n" +
"**" +
' help**: this message\n' +
'**' +
command +
" CURRENCY**: show the price of 1 LBC in CURRENCY. Supported values for CURRENCY are Listed Below\n" +
"**" +
' CURRENCY**: show the price of 1 LBC in CURRENCY. Supported values for CURRENCY are Listed Below\n' +
'**' +
command +
" CURRENCY AMOUNT**: show the price of AMOUNT LBC in CURRENCY\n" +
"**Supported Currencies:** *usd*, *gbp*, *eur*, *aud*, *brl*, *cad*, *chf*, *clp*, *cny*, *dkk*, *hkd*, *inr*, *isk*, *jpy*, *krw*, *nzd*, *pln* ,*rub*, *sek*, *sgd*, *thb*, *twd*, *idr* and *btc* (case-insensitive)";
' CURRENCY AMOUNT**: show the price of AMOUNT LBC in CURRENCY\n' +
'**Supported Currencies:** *usd*, *gbp*, *eur*, *aud*, *brl*, *cad*, *chf*, *clp*, *cny*, *dkk*, *hkd*, *inr*, *isk*, *jpy*, *krw*, *nzd*, *pln* ,*rub*, *sek*, *sgd*, *thb*, *twd*, *idr* and *btc* (case-insensitive)';
msg.channel.send(message);
}
function formatMessage(amount, rate, option) {
var cur = option.sign;
var value = numeral(rate.rate * amount).format(option.format);
return (
"*" +
numeral(amount).format("0,0[.][00000000]") +
" LBC = " +
cur +
" " +
value +
"*\n_last updated " +
rate.time.utc().format(options.dtFormat) +
"_"
);
return '*' + numeral(amount).format('0,0[.][00000000]') + ' LBC = ' + cur + ' ' + value + '*\n_last updated ' + rate.time.utc().format(options.dtFormat) + '_';
}
function doSteps(bot, currency, amount) {
@ -330,9 +313,7 @@ exports.price = {
var shouldReload = true;
if (cachedRates[currency]) {
var cache = cachedRates[currency];
shouldReload =
cache.time === null ||
moment().diff(cache.time) >= options.refreshTime;
shouldReload = cache.time === null || moment().diff(cache.time) >= options.refreshTime;
if (!shouldReload) {
var message = formatMessage(amount, cache, option);
msg.channel.send(message);
@ -354,22 +335,14 @@ exports.price = {
if (steps.length > 0) {
var pairName = steps[0];
if (!options.api[pairName]) {
msg.channel.send(
"There was a configuration error. " +
pairName +
" pair was not found."
);
msg.channel.send('There was a configuration error. ' + pairName + ' pair was not found.');
return;
}
var 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."
);
msg.channel.send(err.message ? err.message : 'The request could not be completed at this time. Please try again later.');
return;
}
var pairRate = 0;
@ -398,9 +371,7 @@ exports.price = {
cachedRates[currency] = result;
msg.channel.send(formatMessage(amount, result, option));
} else {
msg.channel.send(
"The rate returned for the " + pairName + " pair was invalid."
);
msg.channel.send('The rate returned for the ' + pairName + ' pair was invalid.');
}
});
}

View file

@ -1,13 +1,13 @@
let hasPerms = require("../helpers.js").hasPerms;
let inPrivate = require("../helpers.js").inPrivate;
let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require('../helpers.js').inPrivate;
exports.commands = [
"purge" // command that is in this file, every command needs it own export as shown below
'purge' // command that is in this file, every command needs it own export as shown below
];
exports.purge = {
usage: "<number of messages>",
description: "Deletes Messages",
usage: '<number of messages>',
description: 'Deletes Messages',
process: function(bot, msg, suffix) {
if (inPrivate(msg)) {
msg.channel.send("You Cant Purge Message In DM's!");
@ -15,7 +15,7 @@ exports.purge = {
}
if (hasPerms(msg)) {
if (!suffix) {
var newamount = "2";
var newamount = '2';
} else {
var amount = Number(suffix);
var adding = 1;
@ -29,25 +29,15 @@ exports.purge = {
.then(messages => {
msg.channel.bulkDelete(messages);
// Logging the number of messages deleted on both the channel and console.
msg.channel
.send(
"Deletion of messages successful. \n Total messages deleted including command: " +
newamount
)
.then(message => message.delete(5000));
console.log(
"Deletion of messages successful. \n Total messages deleted including command: " +
newamount
);
msg.channel.send('Deletion of messages successful. \n Total messages deleted including command: ' + newamount).then(message => message.delete(5000));
console.log('Deletion of messages successful. \n Total messages deleted including command: ' + newamount);
})
.catch(err => {
console.log("Error while doing Bulk Delete");
console.log('Error while doing Bulk Delete');
console.log(err);
});
} else {
msg.channel
.send("only moderators can use this command!")
.then(message => message.delete(5000));
msg.channel.send('only moderators can use this command!').then(message => message.delete(5000));
}
}
};

View file

@ -1,25 +1,25 @@
let request = require("request");
let config = require("config");
let hasPerms = require("../helpers.js").hasPerms;
let inPrivate = require("../helpers.js").inPrivate;
let ChannelID = config.get("gitrelease").channel;
let request = require('request');
let config = require('config');
let hasPerms = require('../helpers.js').hasPerms;
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",
usage: '',
description: 'gets current release notes from GITHUB',
process: function(bot, msg, suffix) {
var headers = {
"Content-Type": "application/json",
"User-Agent": "Super Agent/0.0.1"
'Content-Type': 'application/json',
'User-Agent': 'Super Agent/0.0.1'
};
// Configure the request
var options = {
url: "https://api.github.com/repos/lbryio/lbry-app/releases/latest",
method: "GET",
url: 'https://api.github.com/repos/lbryio/lbry-app/releases/latest',
method: 'GET',
headers: headers
};
@ -32,19 +32,18 @@ exports.releasenotes = {
if (releasemessage.length < 2000) {
message = {
embed: {
title: "*Download " + releasename + " here!*",
title: '*Download ' + releasename + ' here!*',
description: releasemessage,
url: releaseurl,
color: 7976557,
timestamp: releasedate,
author: {
name: "Lbry-app Release Notes for " + releasename,
icon_url:
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
name: 'Lbry-app Release Notes for ' + releasename,
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: "https://i.imgur.com/yWf5USu.png",
text: "Lbry-app Updated "
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
@ -52,18 +51,18 @@ exports.releasenotes = {
msg.channel.send(message);
return;
}
if (hasPerms(msg) && suffix === "post") {
if (hasPerms(msg) && suffix === 'post') {
bot.channels.get(ChannelID).send(message);
} else {
msg.channel.send(msg.author + " Release notes sent via DM");
msg.channel.send(msg.author + ' Release notes sent via DM');
msg.author.send(message);
}
} else {
message = releasemessage
.trim()
.split("###")
.split('###')
.filter(function(n) {
return n !== "";
return n !== '';
});
releasemessage1 = message[0];
releasemessage2 = message[1];
@ -72,19 +71,18 @@ exports.releasenotes = {
releasemessage5 = message[4];
message1 = {
embed: {
title: "*Download " + releasename + " here!*",
title: '*Download ' + releasename + ' here!*',
description: releasemessage1,
url: releaseurl,
color: 7976557,
timestamp: releasedate,
author: {
name: "Lbry-app Release Notes for " + releasename,
icon_url:
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
name: 'Lbry-app Release Notes for ' + releasename,
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: "https://i.imgur.com/yWf5USu.png",
text: "Lbry-app Updated "
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
@ -94,12 +92,11 @@ exports.releasenotes = {
color: 7976557,
timestamp: releasedate,
author: {
icon_url:
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: "https://i.imgur.com/yWf5USu.png",
text: "Lbry-app Updated "
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
@ -109,12 +106,11 @@ exports.releasenotes = {
color: 7976557,
timestamp: releasedate,
author: {
icon_url:
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: "https://i.imgur.com/yWf5USu.png",
text: "Lbry-app Updated "
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
@ -124,12 +120,11 @@ exports.releasenotes = {
color: 7976557,
timestamp: releasedate,
author: {
icon_url:
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: "https://i.imgur.com/yWf5USu.png",
text: "Lbry-app Updated "
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
@ -139,12 +134,11 @@ exports.releasenotes = {
color: 7976557,
timestamp: releasedate,
author: {
icon_url:
"http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png"
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: "https://i.imgur.com/yWf5USu.png",
text: "Lbry-app Updated "
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
@ -156,14 +150,14 @@ exports.releasenotes = {
msg.channel.send(message5);
return;
}
if (hasPerms(msg) && suffix === "post") {
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);
} else {
msg.channel.send(msg.author + " Release notes sent via DM");
msg.channel.send(msg.author + ' Release notes sent via DM');
msg.author.send(message1);
msg.author.send(message2);
msg.author.send(message3);

View file

@ -1,20 +1,20 @@
let config = require("config");
let botconfig = config.get("bot");
let rolelist = config.get("rolelist");
let config = require('config');
let botconfig = config.get('bot');
let rolelist = config.get('rolelist');
exports.commands = [
"addrole", // command that is in this file, every command needs it own export as shown below
"delrole",
"roles"
'addrole', // command that is in this file, every command needs it own export as shown below
'delrole',
'roles'
];
exports.addrole = {
usage: "<role>",
description: "Adds you to specified role",
usage: '<role>',
description: 'Adds you to specified role',
process: function(bot, msg, suffix) {
// Here the bot,msg and suffix is avaible, this function can be async if needed.
var newrole = msg.guild.roles.find("name", suffix);
let newrole = msg.guild.roles.find('name', suffix);
let baserole = msg.guild.roles.find('name', rolelist.baserole);
// Checks if the user put a role in the message.
if (suffix) {
// Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config.
@ -22,48 +22,35 @@ exports.addrole = {
// 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 (!msg.member.roles.find('name', suffix)) {
msg.member.addRole(newrole).then(msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!'));
if (baserole !== null) {
if (!msg.member.roles.find('name', 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 + " 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!"
);
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!"
);
msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!');
}
} else {
msg.channel.send(
"That role isn't one you can add yourself too! Please run the " +
botconfig.prefix +
"roles command to find out which ones are allowed."
);
msg.channel.send("That role isn't one you can add yourself too! 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!"
);
msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
}
}
};
exports.delrole = {
usage: "<role>",
description: "Deletes your role specified",
usage: '<role>',
description: 'Deletes your role specified',
process: function(bot, msg, suffix) {
// Here the bot,msg and suffix is avaible, this function can be async if needed.
let oldrole = msg.guild.roles.find("name", suffix);
let oldrole = msg.guild.roles.find('name', suffix);
// Checks if the user put a role in the message.
if (suffix) {
// Checks if the role mentioned in the message is in the allowed roles listed in the wunderbot config.
@ -71,62 +58,52 @@ exports.delrole = {
// Checks if the role even 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!"
)
);
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!"
);
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!"
);
msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!');
}
} else {
msg.channel.send(
"That role isn't one you can add yourself too! Please run the " +
botconfig.prefix +
"roles command to find out which ones are allowed."
);
msg.channel.send("That role isn't one you can add yourself too! 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!"
);
msg.channel.send('Please specify a role. Type ' + botconfig.prefix + 'roles to see which you may add!');
}
}
};
exports.roles = {
usage: "",
description: "displays roles you can give yourself",
usage: '',
description: 'displays roles you can give yourself',
process: function(bot, msg, suffix) {
// Here the bot,msg and suffix is avaible, this function can be async if needed.
msg.channel.send({
embed: {
color: 3447003,
title: "Wunderbot",
description: "You have accessed the rolebot function of Wunderbot!",
title: 'Wunderbot',
description: 'You have accessed the rolebot function of Wunderbot!',
fields: [
{
name: "List of roles",
name: 'List of roles',
value: buildRoleString(rolelist.allowedroles),
inline: false
},
{
name: 'How to add a role to yourself',
value: '!addrole (role) - Adds a specified role to yourself.\n!addrole Certified Troll would add the Certified Troll role.',
inline: false
},
{
name: 'How to remove a role from yourself',
value: '!delrole (role) - Removed a specified role from yourself.\n!delrole Certified Troll would remove the Certified Troll role.',
inline: false
}
],
footer: {
icon_url: msg.author.avatarURL,
text: "Requested by: " + JSON.stringify(msg.author.username)
text: 'Requested by: ' + JSON.stringify(msg.author.username)
}
}
});
@ -135,9 +112,9 @@ exports.roles = {
};
function buildRoleString(roles) {
let str = "";
let str = '';
for (let i = 0; i < roles.length; i++) {
str += "`" + roles[i] + "`" + "\n";
str += '`' + roles[i] + '`' + '\n';
}
return str;
}

View file

@ -2,12 +2,12 @@ const authors = [];
let warned = [];
let banned = [];
let messagelog = [];
let config = require("config");
let botlog = config.get("moderation").logchannel;
let hasPerms = require("../helpers.js").hasPerms;
let inPrivate = require("../helpers.js").inPrivate;
let hasExcludedSpamChannels = require("../helpers.js").hasExcludedSpamChannels;
let hasExcludedSpamUsers = require("../helpers.js").hasExcludedSpamUsers;
let config = require('config');
let botlog = config.get('moderation').logchannel;
let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require('../helpers.js').inPrivate;
let hasExcludedSpamChannels = require('../helpers.js').hasExcludedSpamChannels;
let hasExcludedSpamUsers = require('../helpers.js').hasExcludedSpamUsers;
/**
* Add simple spam protection to your discord server.
@ -16,26 +16,19 @@ let hasExcludedSpamUsers = require("../helpers.js").hasExcludedSpamUsers;
* @return {[type]} [description]
*/
exports.custom = ["antiSpam"];
exports.custom = ['antiSpam'];
exports.antiSpam = function(bot) {
const warnBuffer = 5;
const maxBuffer = 10;
const interval = 1500;
const warningMessage =
", Stop spamming or you will be banned! This is your warning!";
const banMessage = "has been banned for spamming!";
const warningMessage = ', Stop spamming or you will be banned! This is your warning!';
const banMessage = 'has been banned for spamming!';
const maxDuplicatesWarning = 5;
const maxDuplicatesBan = 10;
bot.on("message", msg => {
if (
inPrivate(msg) ||
msg.author.bot ||
hasPerms(msg) ||
hasExcludedSpamChannels(msg) ||
hasExcludedSpamUsers(msg)
) {
bot.on('message', msg => {
if (inPrivate(msg) || msg.author.bot || hasPerms(msg) || hasExcludedSpamChannels(msg) || hasExcludedSpamUsers(msg)) {
return;
}
if (msg.author.id != bot.user.id) {
@ -52,11 +45,7 @@ exports.antiSpam = function(bot) {
// Check how many times the same message has been sent.
let msgMatch = 0;
for (let i = 0; i < messagelog.length; i++) {
if (
messagelog[i].message == msg.content &&
messagelog[i].author == msg.author.id &&
msg.author.id !== bot.user.id
) {
if (messagelog[i].message == msg.content && messagelog[i].author == msg.author.id && msg.author.id !== bot.user.id) {
msgMatch++;
}
}
@ -99,7 +88,7 @@ exports.antiSpam = function(bot) {
*/
function warn(msg, userid) {
warned.push(msg.author.id);
msg.channel.send(msg.author + " " + warningMessage);
msg.channel.send(msg.author + ' ' + warningMessage);
}
/**
@ -117,21 +106,17 @@ exports.antiSpam = function(bot) {
banned.push(msg.author.id);
let user = msg.channel.guild.members.find(
member => member.user.id === msg.author.id
);
let user = msg.channel.guild.members.find(member => member.user.id === msg.author.id);
if (user) {
user
.ban()
.then(member => {
msg.channel.send(msg.author + " " + banMessage);
bot.channels.get(botlog).send(msg.author + " " + banMessage);
msg.channel.send(msg.author + ' ' + banMessage);
bot.channels.get(botlog).send(msg.author + ' ' + banMessage);
return true;
})
.catch(() => {
msg.channel.send(
"insufficient permission to kick " + msg.author + " for spamming."
);
msg.channel.send('insufficient permission to kick ' + msg.author + ' for spamming.');
return false;
});
}

View file

@ -1,56 +1,54 @@
let request = require("request");
let wget = require("wget");
let fs = require("fs");
let config = require("config");
let hasSpeechBotChannels = require("../helpers.js").hasSpeechBotChannels;
let inPrivate = require("../helpers.js").inPrivate;
let ChannelID = config.get("speechbot").mainchannel;
let request = require('request');
let wget = require('wget');
let fs = require('fs');
let config = require('config');
let hasSpeechBotChannels = require('../helpers.js').hasSpeechBotChannels;
let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get('speechbot').mainchannel;
//debug output "true/false" outputs same error as slack message in console if set to true
//if set to false console will be left blank like normal
//some have more info on file details of error
let FullDebug = "true";
let FullDebug = 'true';
//outputs response from speech, very bulk reply
let ResponseDebug = "false";
let ResponseDebug = 'false';
exports.commands = [
"speech" // command that is in this file, every command needs it own export as shown below
'speech' // command that is in this file, every command needs it own export as shown below
];
exports.speech = {
usage: "<name>",
description: "gets top claim from spee.ch, coming soon post to spee.ch",
usage: '<name>',
description: 'gets top claim from spee.ch, coming soon post to spee.ch',
process: function(bot, msg, suffix) {
if (!hasSpeechBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send(
"Please use <#" + ChannelID + "> or DMs to talk to speech bot."
);
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to speech bot.');
return;
}
var command = "!speech";
var command = '!speech';
words = suffix
.trim()
.split(" ")
.split(' ')
.filter(function(n) {
return n !== "";
return n !== '';
});
var imagename = words[0];
//check if image name is help, if it is then do help message
if (imagename == "help") {
if (imagename == 'help') {
doHelp(bot, msg, suffix);
return;
} else {
//check if imagename is defined if not do error
if (imagename === undefined) {
if (FullDebug === "true") {
var message = "`no name provided`";
console.log("no name provided");
if (FullDebug === 'true') {
var message = '`no name provided`';
console.log('no name provided');
msg.channel.send(message);
doHelp(bot, msg, suffix);
return;
} else {
var message = "`no name provided`";
var message = '`no name provided`';
msg.channel.send(message);
doHelp(bot, msg, suffix);
return;
@ -62,19 +60,13 @@ exports.speech = {
//check if a url is provided if none do help message
if (filepath === undefined) {
if (FullDebug === "true") {
var message =
"`no url provided, fetching image from:`\n" +
"https://spee.ch/" +
imagename;
console.log("no url provided");
if (FullDebug === 'true') {
var message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
console.log('no url provided');
msg.channel.send(message);
return;
} else {
var message =
"`no url provided, fetching image from:`\n" +
"https://spee.ch/" +
imagename;
var message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
msg.channel.send(message);
return;
}
@ -87,16 +79,14 @@ exports.speech = {
var linkvalid = url.slice(0, 4);
//check of url provided begins with http in not throw error and help message
if (linkvalid !== "http") {
if (FullDebug === "true") {
var message =
"`error not a valid url, please start with http or https`";
console.log("invalid url provided: " + filepath);
if (linkvalid !== 'http') {
if (FullDebug === 'true') {
var message = '`error not a valid url, please start with http or https`';
console.log('invalid url provided: ' + filepath);
msg.channel.send(message);
return;
} else {
var message =
"`error not a valid url, please start with http or https`";
var message = '`error not a valid url, please start with http or https`';
msg.channel.send(message);
return;
}
@ -105,13 +95,13 @@ exports.speech = {
//function to check if url is an image
var isUriImage = function(uri) {
//make sure we remove any nasty GET params
uri = uri.split("?")[0];
uri = uri.split('?')[0];
//moving on, split the uri into parts that had dots before them
var parts = uri.split(".");
var parts = uri.split('.');
//get the last part ( should be the extension )
var extension = parts[parts.length - 1];
//define some image types to test against
var imageTypes = ["jpg", "jpeg", "tiff", "png", "gif", "bmp"];
var imageTypes = ['jpg', 'jpeg', 'tiff', 'png', 'gif', 'bmp'];
//check if the extension matches anything in the list. if it does set true if not set false
if (imageTypes.indexOf(extension) !== -1) {
return true;
@ -122,15 +112,13 @@ exports.speech = {
//check if url is an image if its not throw error and help message
if (isUriImage(url) === false) {
if (FullDebug === "true") {
var message =
"`error not a valid image url, be sure the link includes a file type`";
console.log("invalid url provided: " + url);
if (FullDebug === 'true') {
var message = '`error not a valid image url, be sure the link includes a file type`';
console.log('invalid url provided: ' + url);
msg.channel.send(message);
return;
} else {
var message =
"`error not a valid image url, be sure the link includes a file type`";
var message = '`error not a valid image url, be sure the link includes a file type`';
msg.channel.send(message);
return;
}
@ -139,49 +127,40 @@ exports.speech = {
var eighteen = words[2];
//check is NSFW if yes or no sets proper value if none
if (
eighteen == "" ||
eighteen == "none" ||
eighteen == undefined ||
eighteen == null ||
eighteen == "no" ||
eighteen == "false" ||
eighteen == false ||
eighteen == "n"
) {
eighteen = "no";
if (eighteen == '' || eighteen == 'none' || eighteen == undefined || eighteen == null || eighteen == 'no' || eighteen == 'false' || eighteen == false || eighteen == 'n') {
eighteen = 'no';
} else {
eighteen = "yes";
eighteen = 'yes';
}
//prepare url for wget
var source = url;
//parse the filename to use to save file
filepath = source.split("/").pop();
filepath = source.split('/').pop();
//set proper directory for downloading image
var outputFile = "speech-uploads/" + filepath;
var outputFile = 'speech-uploads/' + filepath;
//set download directory to current working directory
var dir = process.cwd();
//set full path to directory for speech uploading
var fullpath = dir + "\\speech-uploads\\" + filepath;
var fullpath = dir + '\\speech-uploads\\' + filepath;
//download url via wget
var download = wget.download(url, outputFile);
//check if url is reachable if not throw error
download.on("error", function(err) {
if (FullDebug === "true") {
console.log("error could not reach: " + url + " : " + err);
var message = "`error url could not be reached`";
download.on('error', function(err) {
if (FullDebug === 'true') {
console.log('error could not reach: ' + url + ' : ' + err);
var message = '`error url could not be reached`';
msg.channel.send(message);
return;
} else {
var message = "`error url could not be reached`";
var message = '`error url could not be reached`';
msg.channel.send(message);
return;
}
});
download.on("end", output => {
download.on('end', output => {
//if no errors and file ready -> do the request
output && doSteps(bot, imagename, url, eighteen);
});
@ -191,17 +170,17 @@ exports.speech = {
function doHelp(bot, msg, suffix) {
msg.channel.send({
embed: {
title: "",
title: '',
description:
"**!speech `<Name>`** : *displays top claim on speech* \n\n\n" +
"**COMING SOON POSTING TO SPEECH** \n\n" +
"**!speech `<Name> <URL> <NSFW>`** : *Uploads Image URL to Spee.ch* \n" +
"**NOTE : dont include spaces in name (NSFW is optional true/false, if left blank will default to false)** \n" +
"EXAMPLE : `!speech my-image-name https://url/to/image.png false`",
'**!speech `<Name>`** : *displays top claim on speech* \n\n\n' +
'**COMING SOON POSTING TO SPEECH** \n\n' +
'**!speech `<Name> <URL> <NSFW>`** : *Uploads Image URL to Spee.ch* \n' +
'**NOTE : dont include spaces in name (NSFW is optional true/false, if left blank will default to false)** \n' +
'EXAMPLE : `!speech my-image-name https://url/to/image.png false`',
color: 7976557,
author: {
name: "Speech Bot Help",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Speech Bot Help',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
@ -211,7 +190,7 @@ exports.speech = {
function doSteps(bot, imagename, url, eighteen) {
request.post(
//url to send post request
"https://spee.ch/api/publish",
'https://spee.ch/api/publish',
//json payload
{
json: {
@ -223,7 +202,7 @@ exports.speech = {
//get response from server
function(error, response, body) {
//output response if ResponseDebug set to true
if (ResponseDebug === "true") {
if (ResponseDebug === 'true') {
console.log(response);
console.log(error);
console.log(body.success);
@ -231,59 +210,36 @@ exports.speech = {
}
//check speech response for file path error, if found throw internal error!
if (body.message === "no files found in request") {
if (FullDebug === "true") {
console.log("no file found: " + fullpath);
var message =
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
if (body.message === 'no files found in request') {
if (FullDebug === 'true') {
console.log('no file found: ' + fullpath);
var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
} else {
var message =
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
}
}
//check speech response for filename error, if found throw internal error!
if (body.message === "no name field found in request") {
if (FullDebug === "true") {
console.log("no name field found: " + imagename);
var message =
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
if (body.message === 'no name field found in request') {
if (FullDebug === 'true') {
console.log('no name field found: ' + imagename);
var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
} else {
var message =
"`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists";
var message = '`Failed to upload file internally!!`\n please contact <@244245498746241025> or another moderator if the issue persists';
msg.channel.send(message);
return;
}
}
//if no errors post this message
var message =
'uploading... \n "name":"' +
imagename +
'",\n "URL": "' +
url +
'",\n "nsfw":"' +
eighteen +
'"\n to spee.ch';
console.log(
'uploading... \n "name":"' +
imagename +
'",\n "file name": "' +
filepath +
'",\n "url":"' +
url +
'"\n "path":"' +
fullpath +
'"\n "nsfw": "' +
eighteen +
'"'
);
var message = 'uploading... \n "name":"' + imagename + '",\n "URL": "' + url + '",\n "nsfw":"' + eighteen + '"\n to spee.ch';
console.log('uploading... \n "name":"' + imagename + '",\n "file name": "' + filepath + '",\n "url":"' + url + '"\n "path":"' + fullpath + '"\n "nsfw": "' + eighteen + '"');
msg.channel.send(message);
}
);

View file

@ -1,152 +1,143 @@
let jp = require("jsonpath");
let moment = require("moment");
let numeral = require("numeral");
let request = require("request");
let config = require("config");
let needle = require("needle");
let hasStatsBotChannels = require("../helpers.js").hasStatsBotChannels;
let inPrivate = require("../helpers.js").inPrivate;
let ChannelID = config.get("statsbot").mainchannel;
let statsurl = "https://coinmarketcap.com/currencies/library-credit/";
let jp = require('jsonpath');
let moment = require('moment');
let numeral = require('numeral');
let request = require('request');
let config = require('config');
let needle = require('needle');
let hasStatsBotChannels = require('../helpers.js').hasStatsBotChannels;
let inPrivate = require('../helpers.js').inPrivate;
let ChannelID = config.get('statsbot').mainchannel;
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",
usage: '',
description: 'Displays list of current Market stats',
process: function(bot, msg) {
needle.get(
"https://api.coinmarketcap.com/v1/ticker/library-credit/",
function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available");
} else {
var data = response.body[0];
var rank = data.rank;
var price_usd = Number(data.price_usd);
var price_btc = Number(data.price_btc);
var market_cap_usd = Number(data.market_cap_usd);
var available_supply = Number(data.available_supply);
var total_supply = Number(data.total_supply);
var percent_change_1h = Number(data.percent_change_1h);
var percent_change_24h = Number(data.percent_change_24h);
var json = response.body[0];
var newjson = parse_obj(json);
var parse = JSON.stringify(newjson);
var volume24_usd = parse.replace(/[^0-9]/g, "");
var dt = new Date();
var timestamp = dt.toUTCString();
var hr_indicator = ":thumbsup:";
var day_indicator = ":thumbsup:";
if (percent_change_1h < 0) {
hr_indicator = ":thumbsdown:";
}
if (percent_change_24h < 0) {
day_indicator = ":thumbsdown:";
}
needle.get('https://api.coinmarketcap.com/v1/ticker/library-credit/', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('coinmarketcap API is not available');
} else {
var data = response.body[0];
var rank = data.rank;
var price_usd = Number(data.price_usd);
var price_btc = Number(data.price_btc);
var market_cap_usd = Number(data.market_cap_usd);
var available_supply = Number(data.available_supply);
var total_supply = Number(data.total_supply);
var percent_change_1h = Number(data.percent_change_1h);
var percent_change_24h = Number(data.percent_change_24h);
var json = response.body[0];
var newjson = parse_obj(json);
var parse = JSON.stringify(newjson);
var volume24_usd = parse.replace(/[^0-9]/g, '');
var dt = new Date();
var timestamp = dt.toUTCString();
var hr_indicator = ':thumbsup:';
var day_indicator = ':thumbsup:';
if (percent_change_1h < 0) {
hr_indicator = ':thumbsdown:';
}
if (percent_change_24h < 0) {
day_indicator = ':thumbsdown:';
}
needle.get(
"https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=GBP",
function(error, response) {
needle.get('https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=GBP', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('coinmarketcap API is not available');
} else {
var data = response.body[0];
var price_gbp = Number(data.price_gbp);
needle.get('https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=EUR', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available");
msg.channel.send('coinmarketcap API is not available');
} else {
var data = response.body[0];
var price_gbp = Number(data.price_gbp);
needle.get(
"https://api.coinmarketcap.com/v1/ticker/library-credit/?convert=EUR",
function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send("coinmarketcap API is not available");
} else {
var data = response.body[0];
var price_eur = Number(data.price_eur);
description =
"**Rank: [" +
rank +
"](" +
statsurl +
")**\n" +
"**Data**\n" +
"Market Cap: [$" +
numberWithCommas(market_cap_usd) +
"](" +
statsurl +
") \n" +
"Total Supply: [" +
numberWithCommas(total_supply) +
" LBC](" +
statsurl +
")\n" +
"Circulating Supply: [" +
numberWithCommas(available_supply) +
" LBC](" +
statsurl +
")\n" +
"24 Hour Volume: [$" +
volume24_usd +
"](" +
statsurl +
") \n\n" +
"**Price**\n" +
"BTC: [₿" +
price_btc.toFixed(8) +
"](" +
statsurl +
")\n" +
"USD: [$" +
price_usd.toFixed(2) +
"](" +
statsurl +
") \n" +
"EUR: [€" +
price_eur.toFixed(2) +
"](" +
statsurl +
") \n" +
"GBP: [£" +
price_gbp.toFixed(2) +
"](" +
statsurl +
") \n\n" +
"**% Change**\n" +
"1 Hour: [" +
percent_change_1h +
"](" +
statsurl +
") " +
hr_indicator +
" \n\n" +
"1 Day: [" +
percent_change_24h +
"](" +
statsurl +
") " +
day_indicator +
" \n\n";
const embed = {
description: description,
color: 7976557,
footer: {
text: "Last Updated: " + timestamp
},
author: {
name: "Coin Market Cap Stats (LBC)",
url: statsurl,
icon_url: "https://i.imgur.com/yWf5USu.png"
}
};
msg.channel.send({ embed });
}
var price_eur = Number(data.price_eur);
description =
'**Rank: [' +
rank +
'](' +
statsurl +
')**\n' +
'**Data**\n' +
'Market Cap: [$' +
numberWithCommas(market_cap_usd) +
'](' +
statsurl +
') \n' +
'Total Supply: [' +
numberWithCommas(total_supply) +
' LBC](' +
statsurl +
')\n' +
'Circulating Supply: [' +
numberWithCommas(available_supply) +
' LBC](' +
statsurl +
')\n' +
'24 Hour Volume: [$' +
volume24_usd +
'](' +
statsurl +
') \n\n' +
'**Price**\n' +
'BTC: [₿' +
price_btc.toFixed(8) +
'](' +
statsurl +
')\n' +
'USD: [$' +
price_usd.toFixed(2) +
'](' +
statsurl +
') \n' +
'EUR: [€' +
price_eur.toFixed(2) +
'](' +
statsurl +
') \n' +
'GBP: [£' +
price_gbp.toFixed(2) +
'](' +
statsurl +
') \n\n' +
'**% Change**\n' +
'1 Hour: [' +
percent_change_1h +
'](' +
statsurl +
') ' +
hr_indicator +
' \n\n' +
'1 Day: [' +
percent_change_24h +
'](' +
statsurl +
') ' +
day_indicator +
' \n\n';
const embed = {
description: description,
color: 7976557,
footer: {
text: 'Last Updated: ' + timestamp
},
author: {
name: 'Coin Market Cap Stats (LBC)',
url: statsurl,
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
);
};
msg.channel.send({ embed });
}
}
);
}
});
}
});
}
);
});
function parse_obj(obj) {
var array = [];
var prop;
@ -154,7 +145,7 @@ exports.stats = {
if (obj.hasOwnProperty(prop)) {
var key = parseInt(prop, 10);
var value = obj[prop];
if (typeof value == "object") {
if (typeof value == 'object') {
value = parse_obj(value);
}
array[key] = value;
@ -163,7 +154,7 @@ exports.stats = {
return array;
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};

View file

@ -1,35 +1,35 @@
"use strict";
'use strict';
//let config = require("config");
//let rolelist = config.get("rolelist");
const Discord = require("discord.js");
const Discord = require('discord.js');
let initialized = false;
let discordBot = null;
module.exports = {
init: init
init: init
};
function init(discordBot_) {
if (initialized) {
throw new Error("init was already called once");
}
if (initialized) {
throw new Error('init was already called once');
}
discordBot = discordBot_;
discordBot = discordBot_;
discordBot.on("message", checkForCommand);
discordBot.on('message', checkForCommand);
}
/**
*
* @param {String} message
*/
let checkForCommand = function (message) {
//if the close command is found
if (!message.author.bot && message.content.toLowerCase().indexOf('!close') >= 0) {
//send the -close command twice with a 4 seconds timeout
message.channel.send("-close").catch(console.error);
setTimeout(() => {
message.channel.send("-close").catch(console.error);
}, 4000);
}
};
let checkForCommand = function(message) {
//if the close command is found
if (!message.author.bot && message.content.toLowerCase().indexOf('!close') >= 0) {
//send the -close command twice with a 4 seconds timeout
message.channel.send('-close').catch(console.error);
setTimeout(() => {
message.channel.send('-close').catch(console.error);
}, 4000);
}
};

View file

@ -1,9 +1,8 @@
"use strict";
exports.commands = ["tip"];
'use strict';
exports.commands = ['tip'];
exports.tip = {
usage: "<subcommand>",
description:
"balance: get your balance\n deposit: get address for your deposits\n withdraw ADDRESS AMOUNT: withdraw AMOUNT credits to ADDRESS\n <user> <amount>: mention a user with @ and then the amount to tip them",
usage: '<subcommand>',
description: 'balance: get your balance\n deposit: get address for your deposits\n withdraw ADDRESS AMOUNT: withdraw AMOUNT credits to ADDRESS\n <user> <amount>: mention a user with @ and then the amount to tip them',
process: function(bot) {
return; // Tipping is now handled by the separate tipbot(in branch tipbot_dc), no need to to anything here...
}

View file

@ -1,217 +1,223 @@
let hasPerms = require("../helpers.js").hasPerms;
let inPrivate = require("../helpers.js").inPrivate;
let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require('../helpers.js').inPrivate;
exports.custom = ["onUserJoin"];
exports.custom = ['onUserJoin'];
exports.onUserJoin = function(bot) {
bot.on("guildMemberAdd", member => {
bot.on('guildMemberAdd', member => {
member.send({
embed: {
title: "*Click here for more info about LBRY!*",
title: '*Click here for more info about LBRY!*',
description:
"**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n" +
"If you are new to LBRY and would like to learn more, see the links at the end of this message. \n" +
"This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n" +
"**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient . **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n",
url: "https://lbry.io/what",
'**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n' +
'If you are new to LBRY and would like to learn more, see the links at the end of this message. \n' +
'This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n' +
'**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient . **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n',
url: 'https://lbry.io/what',
color: 7976557,
author: {
name: "Welcome to LBRY Discord Community",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Welcome to LBRY Discord Community',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {
bot.channels.get('369896313082478594').send(member +
', Please enable Direct Messages from server members to communicate fully with our bot, it is located in the user setting area under Privacy & Safety tab, select the option allow direct messages from server members\nSince the bot could not send you our Welcome message please check the posts in <#428634445176766464> and available commands in <#428661678796832768>'
)
});
member.send({
embed: {
description:
"1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n" +
"2. Do not spam, advertise or post referral links \n" +
"3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n" +
"4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n" +
"5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n" +
"6. Do not direct message and LBRY team or mods without being asked to do so \n" +
"7. Do not request free LBC, begging will not be tolerated \n",
'1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n' +
'2. Do not spam, advertise or post referral links \n' +
'3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n' +
'4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n' +
'5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n' +
'6. Do not direct message and LBRY team or mods without being asked to do so \n' +
'7. Do not request free LBC, begging will not be tolerated \n',
color: 7976557,
author: {
name: "Ground rules",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Ground rules',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
member.send({
embed: {
description:
"1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n" +
"2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n" +
"3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n" +
"4. You can find the LBRY Block explorer at https://explorer.lbry.io \n" +
"5. Want to contribute more? Check out https://lbry.io/faq/contributing \n" +
"6. Are you a dev? Check out the #dev channel \n" +
"7. Want to share something you published? Post it on the #publishers channel \n",
'1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n' +
'2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n' +
'3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n' +
'4. You can find the LBRY Block explorer at https://explorer.lbry.io \n' +
'5. Want to contribute more? Check out https://lbry.io/faq/contributing \n' +
'6. Are you a dev? Check out the #dev channel \n' +
'7. Want to share something you published? Post it on the #publishers channel \n',
color: 7976557,
author: {
name: "Helpful hints",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Helpful hints',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
member.send({
embed: {
title: "*Click here for more info about LBRY!*",
title: '*Click here for more info about LBRY!*',
description:
"[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)",
url: "https://lbry.io/what",
'[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)',
url: 'https://lbry.io/what',
color: 7976557,
author: {
name: "What is LBRY?",
url: "https://lbry.io/what",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'What is LBRY?',
url: 'https://lbry.io/what',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
member.send({
embed: {
title: "*Click here to see all LBRY Frequently Asked Questions (FAQ)!*",
title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description:
"Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)",
url: "https://lbry.io/faq",
'Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)',
url: 'https://lbry.io/faq',
color: 7976557,
author: {
name: "LBRY FAQ",
url: "https://lbry.io/faq",
icon_url: "https://spee.ch/8/Id5Qoc3w.png"
name: 'LBRY FAQ',
url: 'https://lbry.io/faq',
icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
member.send({
embed: {
title: "*Have you checked out spee.ch yet?!*",
title: '*Have you checked out spee.ch yet?!*',
description:
"[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistent and decentralized image and video sharing site with the added benefit of being a web-based (works on mobile too!) gateway into the LBRY network. spee.ch can be used to retrieve LBRY images/videos that are free by accessing them through a web browser. \nFor example, if content is located at lbry://loose-cannons-episode1#12c87bb42dd8832167b1e54edf72bbd37bc47622, you can view it on spee.ch at: https://spee.ch/12c87bb42dd8832167b1e54edf72bbd37bc47622/loose-cannons-episode1. You can also view channels on spee.ch, such as: https://spee.ch/@copchronicles:5c039dc7423657e59d78939df72c186e43273675 or https://spee.ch/@MinutePhysics:589276465a23c589801d874f484cc39f307d7ec7 \n\nspee.ch also allows you to create a channel to group your uploads and retreive them easily. These channels are separate from any you may have in the LBRY app since they exist on the spee.ch site via a login process. You can even share your channel name and password so that others can contribute to it.",
url: "https://spee.ch/about",
url: 'https://spee.ch/about',
color: 7976557,
author: {
name: "spee.ch",
url: "https://spee.ch",
icon_url:
"http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png"
name: 'spee.ch',
url: 'https://spee.ch',
icon_url: 'http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
});
};
exports.commands = [
"welcome" // command that is in this file, every command needs it own export as shown below
'welcome' // command that is in this file, every command needs it own export as shown below
];
exports.welcome = {
usage: "<@username>",
description: "send welcome message to specified user",
usage: '<@username>',
description: 'send welcome message to specified user',
process: function(bot, msg, suffix) {
if (inPrivate(msg)) {
msg.channel.send("command cannot be used in a DM");
msg.channel.send('command cannot be used in a DM');
return;
}
if (suffix == "") {
msg.channel.send("no user defined");
if (suffix == '') {
msg.channel.send('no user defined');
return;
}
if (!hasPerms(msg)) {
msg.channel.send("You Dont Have Permission To Use This Command!");
msg.channel.send('You Dont Have Permission To Use This Command!');
return;
}
msg.mentions.members.first().send({
embed: {
title: "*Click here for more info about LBRY!*",
title: '*Click here for more info about LBRY!*',
description:
"**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n" +
"If you are new to LBRY and would like to learn more, see the links at the end of this message. \n" +
"This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n" +
"**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient, **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n",
url: "https://lbry.io/what",
'**Welcome to LBRY Discord Community, you are now officially a LBRYian!** \n' +
'If you are new to LBRY and would like to learn more, see the links at the end of this message. \n' +
'This community allows LBRYians to interact with the team directly and for us to engage users in order to grow the LBRY platform! \n' +
'**Looking for *Rewards Verification*? Please make a request in the #verification channel by typing **-new** - this will create a ticket (channel) for your request. A mod will reach out to you, please be patient, **Note: DO NOT message any team members or post in other channels about verification concerns.**. Only 1 Reward account is allowed per household** \n',
url: 'https://lbry.io/what',
color: 7976557,
author: {
name: "Welcome to LBRY Discord Community",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Welcome to LBRY Discord Community',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {
msg.channel.send(msg.mentions.members.first() +
', Please enable Direct Messages from server members to communicate fully with our bot, it is located in the user setting area under Privacy & Safety tab, select the option allow direct messages from server members'
)
});
msg.mentions.members.first().send({
embed: {
description:
"1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n" +
"2. Do not spam, advertise or post referral links \n" +
"3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n" +
"4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n" +
"5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n" +
"6. Do not direct message and LBRY team or mods without being asked to do so \n" +
"7. Do not request free LBC, begging will not be tolerated \n",
'1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n' +
'2. Do not spam, advertise or post referral links \n' +
'3. Use appropriate channels for your discussions/questions. If you are looking for help with LBRY, use #help, for price talk, use #market-and-trading \n' +
'4. #general discussions should be at least somewhat related to LBRY, otherwise there is #random \n' +
'5. Do not post **not safe for work (NFSW)** content in any non-marked channels, there is #random-nsfw for that \n' +
'6. Do not direct message and LBRY team or mods without being asked to do so \n' +
'7. Do not request free LBC, begging will not be tolerated \n',
color: 7976557,
author: {
name: "Ground rules",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Ground rules',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
msg.mentions.members.first().send({
embed: {
description:
"1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n" +
"2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n" +
"3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n" +
"4. You can find the LBRY Block explorer at https://explorer.lbry.io \n" +
"5. Want to contribute more? Check out https://lbry.io/faq/contributing \n" +
"6. Are you a dev? Check out the #dev channel \n" +
"7. Want to share something you published? Post it on the #publishers channel \n",
'1. Type !tip help in the #bot-sandbox channel to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). **Enable 2FA in your Discord account settings!** \n' +
'2. See the Frequently Asked Questions (FAQ) section below prior to asking for help or information on LBRY \n' +
'3. Backing up your LBRY wallet is your responsbility, see FAQ link below \n' +
'4. You can find the LBRY Block explorer at https://explorer.lbry.io \n' +
'5. Want to contribute more? Check out https://lbry.io/faq/contributing \n' +
'6. Are you a dev? Check out the #dev channel \n' +
'7. Want to share something you published? Post it on the #publishers channel \n',
color: 7976557,
author: {
name: "Helpful hints",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'Helpful hints',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
msg.mentions.members.first().send({
embed: {
title: "*Click here for more info about LBRY!*",
title: '*Click here for more info about LBRY!*',
description:
"[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)",
url: "https://lbry.io/what",
'[**LBRY**](https://lbry.io) is a protocol providing fully decentralized network for the discovery, distribution, and payment of data. It utilizes the [**LBRY blockchain**](https://lbry.io/what#the-network) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, and rights and access rules. \n[_**Download the LBRY App here**_](https://lbry.io/get)',
url: 'https://lbry.io/what',
color: 7976557,
author: {
name: "What is LBRY?",
url: "https://lbry.io/what",
icon_url: "https://i.imgur.com/yWf5USu.png"
name: 'What is LBRY?',
url: 'https://lbry.io/what',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
msg.mentions.members.first().send({
embed: {
title: "*Click here to see all LBRY Frequently Asked Questions (FAQ)!*",
title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description:
"Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)",
url: "https://lbry.io/faq",
'Want to backup your LBRY wallet? [**Backup**](https://lbry.io/faq/how-to-backup-wallet) \nLooking for LBRY data? [**Behind the scenes files**](https://lbry.io/faq/lbry-directories) \nTrouble starting LBRY? [**Startup troubleshooting**](https://lbry.io/faq/startup-troubleshooting) \nNeed help finding your log files (will help us troubleshoot!)? [**Find logs**](https://lbry.io/faq/how-to-find-lbry-log-file) \nNot able to stream any content? [**Troublshoot streaming**](https://lbry.io/faq/unable-to-stream)\nNeed help with publishing? [**How to Publish**](https://lbry.io/faq/how-to-publish) \nWant more LBRY Credits (LBC)? [**Get LBC**](https://lbry.io/faq/earn-credits) \nLooking for referral information? [**Referrals**](https://lbry.io/faq/referrals)',
url: 'https://lbry.io/faq',
color: 7976557,
author: {
name: "LBRY FAQ",
url: "https://lbry.io/faq",
icon_url: "https://spee.ch/8/Id5Qoc3w.png"
name: 'LBRY FAQ',
url: 'https://lbry.io/faq',
icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
}
}
});
}).catch(console.error).then(console.log('could not send dm'));
msg.mentions.members.first().send({
embed: {
title: "*Have you checked out spee.ch yet?!*",
title: '*Have you checked out spee.ch yet?!*',
description:
"[**spee.ch**](https://spee.ch) runs on top of the LBRY network - it's essentially an open source, censorship resistent and decentralized image and video sharing site with the added benefit of being a web-based (works on mobile too!) gateway into the LBRY network. spee.ch can be used to retrieve LBRY images/videos that are free by accessing them through a web browser. \nFor example, if content is located at lbry://loose-cannons-episode1#12c87bb42dd8832167b1e54edf72bbd37bc47622, you can view it on spee.ch at: https://spee.ch/12c87bb42dd8832167b1e54edf72bbd37bc47622/loose-cannons-episode1. You can also view channels on spee.ch, such as: https://spee.ch/@copchronicles:5c039dc7423657e59d78939df72c186e43273675 or https://spee.ch/@MinutePhysics:589276465a23c589801d874f484cc39f307d7ec7 \n\nspee.ch also allows you to create a channel to group your uploads and retreive them easily. These channels are separate from any you may have in the LBRY app since they exist on the spee.ch site via a login process. You can even share your channel name and password so that others can contribute to it.",
url: "https://spee.ch/about",
url: 'https://spee.ch/about',
color: 7976557,
author: {
name: "spee.ch",
url: "https://spee.ch",
icon_url:
"http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png"
name: 'spee.ch',
url: 'https://spee.ch',
icon_url: 'http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png'
}
}
});
}).catch(function(error) {console.log('could not send dm')});
}
};

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,10 @@
"prefix": "!",
"debug": false
},
"moderation": {
"perms": ["Moderator Team","LBRY TEAM"], // Roles that have access to all commands.
"logchannel": "371620338263523328" // Channel to log the bots moderation..
},
"lbrycrd": {
"port": 9245,
"user": "user",
@ -76,10 +80,9 @@
"mainchannel": "363050205043621908" // Main Stats Bot channel for directing with help message
},
"rolelist": {
"allowedroles": [
"Reward Scammer",
"Reported Scammer"
]
// The roles here are Case Sensitive to how they are in your Discord Server!
"baserole": "LBRYian",
"allowedroles": ["NSFW", "Marketers", "Miners", "Off-Topic Chats"]
},
"claimbot": {
"channels": [

1924
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,26 +4,26 @@
"babel-preset-node8": "^1.2.0",
"bitcoin": "^3.0.1",
"chrono-node": "^1.3.5",
"config": "^1.27.0",
"discord.js": "^11.2.1",
"config": "^1.30.0",
"discord.js": "^11.3.2",
"elmadev-discord-irc": "^2.4.1",
"embed-creator": "^1.1.4",
"jsonpath": "^0.2.12",
"moment": "^2.19.1",
"mongoose": "^4.12.3",
"embed-creator": "^1.2.3",
"jsonpath": "^1.0.0",
"moment": "^2.21.0",
"mongoose": "^4.13.12",
"needle": "^2.0.1",
"node-config": "^0.0.2",
"numeral": "^2.0.6",
"request": "^2.83.0",
"request": "^2.85.0",
"sleep": "^5.1.1",
"wget": "^0.0.1"
},
"scripts": {
"prettier": "prettier * --write",
"prettier": "prettier --write \"{bot,.}/**/*.{js,json}\" --single-quote --print-width 240",
"build": "babel bot -d dist",
"prod": "babel bot -d dist & node dist/bot.js",
"lint": "prettier --write bot/**/*.js",
"precommit": "prettier --write bot/**/*.js"
"lint": "prettier --write \"{bot,.}/**/*.{js,json}\" --single-quote --print-width 240",
"precommit": "prettier --write \"{bot,.}/**/*.{js,json}\" --single-quote --print-width 240"
},
"devDependencies": {
"husky": "^0.14.3",