Removed ALL the old files..

This commit is contained in:
filipnyquist 2018-05-19 23:38:31 +02:00
parent adbf5d6bf9
commit 0268a9b654
24 changed files with 0 additions and 5708 deletions

View file

@ -1,217 +0,0 @@
'use strict';
// Load up libraries
const Discord = require('discord.js');
// Load config!
let config = require('config');
config = config.get('bot');
//load modules
const claimbot = require('./modules/claimbot.js');
const commandsV2 = require('./modules/commandsV2.js');
const supportbot = require('./modules/supportbot.js');
var aliases;
try {
aliases = require('./alias.json');
} catch (e) {
//No aliases defined
aliases = {
test: {
process: function(bot, msg) {
msg.channel.send('test');
}
}
};
}
var commands = {
ping: {
description: 'responds pong, useful for checking if bot is alive',
process: async function(bot, msg, suffix) {
let m = await msg.channel.send(msg.author + ' Ping?');
m.edit(`Pong! Latency is ${m.createdTimestamp - msg.createdTimestamp}ms. API Latency is ${Math.round(bot.ping)}ms`);
if (suffix) {
msg.channel.send('note that !ping takes no arguments!');
}
}
}
};
var bot = new Discord.Client();
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
.setActivity(config.prefix + 'help', { type: 'LISTENING' })
.catch(console.error);
//initialize the claimbot (content bot)
claimbot.init(bot);
//initialize the commandsBot
commandsV2.init(bot);
//initialize the support bot
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)) {
//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)) {
try {
cmdTxt = msg.content.split(' ')[1];
suffix = msg.content.substring(bot.user.mention().length + cmdTxt.length + config.prefix.length + 1);
} catch (e) {
//no command
msg.channel.send('Yes?');
return;
}
}
let alias = aliases[cmdTxt];
if (alias) {
var cmd = alias;
} else {
var cmd = commands[cmdTxt];
}
if (cmdTxt === 'help') {
//help is special since it iterates over the other commands
if (suffix) {
var cmds = suffix.split(' ').filter(function(cmd) {
return commands[cmd];
});
var info = '';
for (var i = 0; i < cmds.length; i++) {
var cmd = cmds[i];
info += '**' + config.prefix + cmd + '**';
var usage = commands[cmd].usage;
if (usage) {
info += ' ' + usage;
}
var description = commands[cmd].description;
if (description instanceof Function) {
description = description();
}
if (description) {
info += '\n\t' + description;
}
info += '\n';
}
msg.channel.send(info);
} else {
msg.author.send('**Available Commands:**').then(function() {
var batch = '';
var sortedCommands = Object.keys(commands).sort();
for (var i in sortedCommands) {
var cmd = sortedCommands[i];
var info = '**' + config.prefix + cmd + '**';
var usage = commands[cmd].usage;
if (usage) {
info += ' ' + usage;
}
var description = commands[cmd].description;
if (description instanceof Function) {
description = description();
}
if (description) {
info += '\n\t' + description;
}
var newBatch = batch + '\n' + info;
if (newBatch.length > 1024 - 8) {
//limit message length
msg.author.send(batch);
batch = info;
} else {
batch = newBatch;
}
}
if (batch.length > 0) {
msg.author.send(batch);
}
});
}
} 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) {
var msgTxt = 'command ' + cmdTxt + ' failed :(';
if (config.debug) {
msgTxt += '\n' + e.stack;
}
msg.channel.send(msgTxt);
}
} else {
//msg.channel.send(cmdTxt + ' not recognized as a command!').then(message => message.delete(10000));
}
} else {
//message isn't a command or is from us
//drop our own messages to prevent feedback loops
if (msg.author == bot.user) {
return;
}
if (msg.author != bot.user && msg.isMentioned(bot.user)) {
msg.channel.send('yes?'); //using a mention here can lead to looping
} else {
}
}
}
bot.on('message', msg => checkMessageForCommand(msg, false));
bot.on('messageUpdate', (oldMessage, newMessage) => {
checkMessageForCommand(newMessage, true);
});
exports.addCommand = function(commandName, commandObject) {
try {
commands[commandName] = commandObject;
} catch (err) {
console.log(err);
}
};
exports.addCustomFunc = function(customFunc) {
try {
customFunc(bot);
} catch (err) {
console.log(err);
}
};
exports.commandCount = function() {
return Object.keys(commands).length;
};
bot.login(config.token);

View file

@ -1,47 +0,0 @@
let config = require('config');
let permRanks = config.get('moderation');
let speechBotChannels = config.get('speechbot');
let priceBotChannels = config.get('pricebot');
let ExcludedSpam = config.get('spamdetection');
let hashBotChannels = config.get('hashbot');
let statsBotChannels = config.get('statsbot');
// Checks if user is allowed to use a command only for mods/team members
exports.hasPerms = function(msg) {
return msg.member.roles !== null && msg.member.roles.some(r => permRanks.perms.includes(r.name));
};
// Check if command was sent in dm
exports.inPrivate = function(msg) {
return msg.channel.type == 'dm';
};
// Checks if Message was sent from a channel in speechBot Channels list
exports.hasSpeechBotChannels = function(msg) {
return speechBotChannels.channels.includes(msg.channel.id);
};
// Checks if Message was sent from a channel in priceBot Channels list
exports.hasPriceBotChannels = function(msg) {
return priceBotChannels.channels.includes(msg.channel.id);
};
// Checks if Message was sent from a Excluded channel
exports.hasExcludedSpamChannels = function(msg) {
return ExcludedSpam.channels.includes(msg.channel.id);
};
// Checks if Message was sent from a Excluded user
exports.hasExcludedSpamUsers = function(msg) {
return ExcludedSpam.users.includes(msg.author.id);
};
// Checks if Message was sent from a channel in hashBot Channels list
exports.hasHashBotChannels = function(msg) {
return hashBotChannels.channels.includes(msg.channel.id);
};
// Checks if Message was sent from a channel in statsBot Channels list
exports.hasStatsBotChannels = function(msg) {
retrun(statsBotChannels.channels.includes(msg.channel.id));
};

View file

@ -1,71 +0,0 @@
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.altprice = {
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.');
return;
}
if (suffix !== '') {
words = suffix
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
});
var currency1 = words[0].toUpperCase();
if (words[1] == undefined) {
var currency2 = 'BTC';
} else {
var currency2 = words[1].toUpperCase();
}
if (words[2] == undefined) {
var amount = '1';
} else {
if (getValidatedAmount(words[2]) === null) {
msg.reply('Please specify a number for <amount>');
return;
}
var amount = words[2].toUpperCase();
}
} else {
var currency1 = 'BTC';
var currency2 = 'USD';
var amount = '1';
}
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');
} else {
if (!response.body.Data.hasOwnProperty(currency1)) {
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);
}
});
}
});
function getValidatedAmount(amount) {
amount = amount.trim();
return amount.match(/^[0-9]+(\.[0-9]+)?$/) ? amount : null;
}
}
};

View file

@ -1,285 +0,0 @@
'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');
module.exports = {
init: init
};
function init(discordBot_) {
if (lbry) {
throw new Error('init was already called once');
}
discordBot = discordBot_;
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'));
console.log('Activating claimbot ');
discordBot.channels.get(channels[0]).send('activating claimbot');
setInterval(function() {
announceNewClaims();
}, 60 * 1000);
announceNewClaims();
});
}
function announceNewClaims() {
if (!mongo) {
discordPost('Failed to connect to mongo', {});
return;
}
if (!lbry) {
discordPost('Failed to connect to lbrycrd', {});
return;
}
Promise.all([getLastBlock(), lbryCall('getinfo')])
.then(function([lastProcessedBlock, currentBlockInfo]) {
const currentHeight = currentBlockInfo['blocks'];
console.log(currentHeight);
if (lastProcessedBlock === null) {
console.log('First run. Setting last processed block to ' + currentHeight + ' and exiting.');
return setLastBlock(currentHeight);
}
const testBlock = false;
if (testBlock || lastProcessedBlock < currentHeight) {
const firstBlockToProcess = testBlock || lastProcessedBlock + 1,
lastBlockToProcess = testBlock || currentHeight;
console.log('Doing blocks ' + firstBlockToProcess + ' to ' + lastBlockToProcess);
return announceClaimsLoop(firstBlockToProcess, lastBlockToProcess, currentHeight);
}
})
.catch(function(err) {
discordPost(err.stack, {});
});
}
function announceClaimsLoop(block, lastBlock, currentHeight) {
let claimsFound = 0;
return lbryCall('getblockhash', block)
.then(function(blockHash) {
return lbryCall('getblock', blockHash);
})
.then(function(blockData) {
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);
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);
return announceClaim(claim, block, currentHeight);
})
);
})
.then(function() {
return setLastBlock(block);
})
.then(function() {
const nextBlock = block + 1;
if (nextBlock <= lastBlock) {
return announceClaimsLoop(nextBlock, lastBlock, currentHeight);
}
});
}
function announceClaim(claim, claimBlockHeight, currentHeight) {
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;
let options = {
method: 'GET',
url: 'http://127.0.0.1:5000/claim_decode/' + claim['name']
};
request(options, function(error, response, body) {
if (error) throw new Error(error);
try {
console.log(JSON.stringify(JSON.parse(body), null, 2));
let claimData = null;
let channelName = null;
try {
body = JSON.parse(body);
if (body.hasOwnProperty('stream') && body.stream.hasOwnProperty('metadata')) {
claimData = body.stream.metadata;
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]) {
//console.log(JSON.stringify(claimData));
let value = null;
if (claimData !== null) value = claimData;
else {
try {
value = JSON.parse(claim['value']);
} catch (e) {}
}
const text = [];
if (value) {
/*
if (channelName) {
text.push("Channel: lbry://" + channelName);
}
else
*/
console.log(value);
if (value['author']) {
text.push('author: ' + value['author']);
}
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*');
}
//"fee":{"currency":"LBC","amount":186,"version":"_0_0_1","address":"bTGoFCakvQXvBrJg1b7FJzombFUu6iRJsk"}
if (value['fee']) {
const fees = [];
text.push('Price: ' + value['fee'].amount + ' *' + value['fee'].currency + '*');
}
if (!claim['is controlling']) {
// the following is based on https://lbry.io/faq/claimtrie-implementation
const lastTakeoverHeight = claimsForName['nLastTakeoverHeight'],
maxDelay = 4032, // 7 days of blocks at 2.5min per block
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;
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'
},
title: 'lbry://' + (channelName ? channelName + '/' : '') + claim['name'],
color: 1399626,
description: escapeSlackHtml(text.join('\n')),
footer: {
text: 'Block ' + claimBlockHeight + ' • Claim ID ' + claim['claimId']
},
image: { url: !value['nsfw'] ? value['thumbnail'] || '' : '' },
url: 'http://open.lbry.io/' + claim['name']
};
discordPost(text, richEmbeded);
}
});
} catch (e) {
console.error(e);
}
});
}
function escapeSlackHtml(txt) {
return txt
.replace('&', '&amp;')
.replace('<', '&lt;')
.replace('>', '&gt;');
}
function getClaimsForTxid(txid) {
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 [];
});
}
function getLastBlock() {
return new Promise(function(resolve, reject) {
mongo.collection('claimbot').findOne({}, function(err, obj) {
if (err) {
reject(err);
} else if (!obj) {
mongo.collection('claimbot').createIndex({ last_block: 1 }, { unique: true });
resolve(null);
} else {
resolve(obj.last_block);
}
});
});
}
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();
}
});
});
}
function discordPost(text, params) {
let richEmbeded = new Discord.RichEmbed(params);
channels.forEach(channel => {
discordBot.channels
.get(channel)
.send('', richEmbeded)
.catch(console.error);
});
}
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(', ') + ']'));
} else {
resolve(...response);
}
});
});
}

View file

@ -1,51 +0,0 @@
'use strict';
let commands = require('../../config/commands');
const Discord = require('discord.js');
let initialized = false;
let discordBot = null;
let commandsList = null;
module.exports = {
init: init
};
function init(discordBot_) {
if (initialized) {
throw new Error('init was already called once');
}
discordBot = discordBot_;
discordBot.on('message', checkForCommand);
}
/**
*
* @param {String} message
*/
let checkForCommand = function(message) {
//build the command list ONLY on first run
let firstRun = false;
if (commandsList === null) {
firstRun = true;
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 a command is found
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));
}
});
//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));
}
};

View file

@ -1,24 +0,0 @@
/*
// Example #1 Command(use this to make your Commands with triggers like !demo)
exports.commands = [
"demo" // command name that will be used for next lines of code below
]
exports.demo = {
usage: "<subcommand>", //command usage like !demo <@username>, exclude !demo
description: 'description of command', //the description of command for !help command
process: function(bot,msg,suffix){
// Here the bot,msg and suffix is available, this function can be async if needed.
}
}
// Example #2 Function(use this to make your Functions that dont need trigger words unlike !demo)
exports.custom = [
"myFunction" //change this to your function name
]
exports.myFunction = function(bot) {
// Other functions that need to be ran once on bootup!
// For example a timed function and or some init stuff..
}
*/

View file

@ -1,209 +0,0 @@
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
];
exports.custom = ['timedhash'];
exports.timedhash = function(bot) {
setInterval(function() {
sendMiningInfo(bot);
}, 6 * 60 * 60 * 1000);
function sendMiningInfo(bot) {
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');
} 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) {
if (error || response.statusCode !== 200) {
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: ' +
numberWithCommas(hashrate) +
'\n' +
'Difficulty: ' +
numberWithCommas(difficulty.toFixed(0)) +
'\n' +
'Difficulty 24 Hour Average: ' +
numberWithCommas(difficulty24.toFixed(0)) +
'\n' +
'Current block: ' +
numberWithCommas(height.toFixed(0)) +
'\n' +
'Block Time: ' +
numberWithCommas(block_time.toFixed(0)) +
' seconds \n' +
'Block Reward: ' +
numberWithCommas(reward.toFixed(0)) +
' 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'
}
};
bot.channels.get(ChannelID).send({ embed });
return;
});
}
});
function numberWithCommas(x) {
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',
process: function(bot, msg, suffix) {
var command = '!hash';
words = suffix
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
});
profitcommand = words[0];
myhashrate = words[1];
if (profitcommand == 'power') {
sendProfitInfo(bot, msg, suffix);
return;
} else {
sendMiningInfo(bot, msg, suffix);
return;
}
function sendMiningInfo(bot, msg, suffix) {
if (!inPrivate(msg) && !hasHashBotChannels(msg)) {
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) {
if (error || response.statusCode !== 200) {
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) {
if (error || response.statusCode !== 200) {
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: ' +
numberWithCommas(hashrate) +
'\n' +
'Difficulty: ' +
numberWithCommas(difficulty.toFixed(0)) +
'\n' +
'Difficulty 24 Hour Average: ' +
numberWithCommas(difficulty24.toFixed(0)) +
'\n' +
'Current block: ' +
numberWithCommas(height.toFixed(0)) +
'\n' +
'Block Time: ' +
numberWithCommas(block_time.toFixed(0)) +
' seconds \n' +
'Block Reward: ' +
numberWithCommas(reward.toFixed(0)) +
' 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'
}
};
msg.channel.send({ embed });
return;
});
}
});
}
function sendProfitInfo(bot, msg, suffix) {
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
if (error || response.statusCode !== 200) {
msg.channel.send('whattomine API is not available');
} else {
words = suffix
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
});
var myhashrate = words[1];
if (myhashrate == '' || myhashrate == null || myhashrate == undefined || myhashrate == ' ') {
myhashrate = '100';
}
var Diff = response.body.difficulty24;
var Reward = response.body.block_reward;
var myHash = Number(myhashrate);
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 message =
'With **' +
myHash +
' Mh/s** and Average 24 hour Difficulty: **' +
Diff.toFixed(0) +
'**\n' +
'You can potentially earn the following amounts of **LBC**: \n' +
'1 Hour = **' +
LBC.toFixed(4) +
'** \n' +
'1 Day = **' +
LBC24.toFixed(2) +
'** \n' +
'1 Week = **' +
LBC1w.toFixed(4) +
'** \n' +
'1 Month = **' +
LBC1m.toFixed(4) +
'** \n';
const embed = {
description: message,
color: 7976557,
author: {
name: 'Hashing Power Calculator!',
icon_url: 'https://i.imgur.com/nKHVQgq.png'
}
};
msg.channel.send({ embed });
return;
}
});
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};

View file

@ -1,8 +0,0 @@
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,88 +0,0 @@
let inPrivate = require('../helpers.js').inPrivate;
let responseDebug = false;
exports.custom = [
'lbrylink' //change this to your function name
];
exports.lbrylink = function(bot, msg, suffix) {
bot.on('message', msg => {
if (inPrivate(msg)) {
return;
}
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);
}
//Check if just lbry:// was supplied
if (newURL == 'https://open.lbry.io/') {
return;
}
//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;
}
//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 {
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" + newURL,
color: 7976557,
author: {
name: 'LBRY Linker',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
};
msg.channel.send({ embed });
}
});
};

View file

@ -1,15 +0,0 @@
/*'use strict';
// Moderation module, handles banning and kicking and more...
let hasPerms = require('../helpers.js').hasPerms;
exports.commands = [
"m"
]
exports.m = {
usage: "<subcommand> <reason>",
description: 'ban: bans the user with the reason\n kick: get adress for your deposits\n',
process: function(bot,msg,suffix){
console.log(msg.member.user);
}
}*/

View file

@ -1,389 +0,0 @@
'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.price = {
usage: '<currency> <amount>',
description: 'displays price of lbc',
process: function(bot, msg, suffix) {
var options = {
defaultCurrency: 'BTC',
// supported currencies and api steps to arrive at the final value
currencies: {
USD: {
steps: ['LBCBTC', 'BTCUSD'],
format: '$0,0.00',
sign: 'USD '
},
GBP: {
steps: ['LBCBTC', 'BTCGBP'],
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$'
},
CAD: {
steps: ['LBCBTC', 'BTCCAD'],
format: '$0,0.00',
sign: 'CAD '
},
CHF: {
steps: ['LBCBTC', 'BTCCHF'],
format: 'CHF 0,0.00',
sign: 'CHF'
},
CLP: {
steps: ['LBCBTC', 'BTCCLP'],
format: '$0,0.00',
sign: 'CLP '
},
CNY: {
steps: ['LBCBTC', 'BTCCNY'],
format: '¥0,0.00',
sign: '¥'
},
DKK: {
steps: ['LBCBTC', 'BTCDKK'],
format: 'kr 0,0.00',
sign: 'kr'
},
EUR: {
steps: ['LBCBTC', 'BTCEUR'],
format: '€0,0.00',
sign: '€'
},
HKD: {
steps: ['LBCBTC', 'BTCHKD'],
format: '$0,0.00',
sign: 'HKD '
},
INR: {
steps: ['LBCBTC', 'BTCINR'],
format: '₹0,0.00',
sign: '₹'
},
ISK: {
steps: ['LBCBTC', 'BTCISK'],
format: 'kr 0,0.00',
sign: 'kr'
},
JPY: {
steps: ['LBCBTC', 'BTCJPY'],
format: '¥0,0.00',
sign: '¥'
},
KRW: {
steps: ['LBCBTC', 'BTCKRW'],
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ł'
},
RUB: {
steps: ['LBCBTC', 'BTCRUB'],
format: 'RUB 0,0.00',
sign: 'RUB'
},
SEK: {
steps: ['LBCBTC', 'BTCSEK'],
format: 'kr 0,0.00',
sign: 'kr'
},
SGD: {
steps: ['LBCBTC', 'BTCSGD'],
format: '$0,0.00',
sign: 'SGD '
},
THB: {
steps: ['LBCBTC', 'BTCTHB'],
format: '฿0,0.00',
sign: '฿'
},
TWD: {
steps: ['LBCBTC', 'BTCTWD'],
format: 'NT$0,0.00',
sign: 'NT$'
},
MYR: {
steps: ['LBCBTC', 'BTCMYR'],
format: 'RM 0,0.00',
sign: 'RM'
},
IDR: {
steps: ['LBCBTC', 'BTCIDR'],
format: 'Rp0,0.00',
sign: 'Rp'
},
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'
},
BTCUSD: {
url: 'https://blockchain.info/ticker',
path: '$.USD.buy'
},
BTCGBP: {
url: 'https://blockchain.info/ticker',
path: '$.GBP.buy'
},
BTCAUD: {
url: 'https://blockchain.info/ticker',
path: '$.AUD.buy'
},
BTCBRL: {
url: 'https://blockchain.info/ticker',
path: '$.BRL.buy'
},
BTCCAD: {
url: 'https://blockchain.info/ticker',
path: '$.CAD.buy'
},
BTCCHF: {
url: 'https://blockchain.info/ticker',
path: '$.CHF.buy'
},
BTCMYR: {
url: 'https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=MYR',
path: '$.MYR'
},
BTCCLP: {
url: 'https://blockchain.info/ticker',
path: '$.CLP.buy'
},
BTCCNY: {
url: 'https://blockchain.info/ticker',
path: '$.CNY.buy'
},
BTCDKK: {
url: 'https://blockchain.info/ticker',
path: '$.DKK.buy'
},
BTCEUR: {
url: 'https://blockchain.info/ticker',
path: '$.EUR.buy'
},
BTCHKD: {
url: 'https://blockchain.info/ticker',
path: '$.HKD.buy'
},
BTCINR: {
url: 'https://blockchain.info/ticker',
path: '$.INR.buy'
},
BTCISK: {
url: 'https://blockchain.info/ticker',
path: '$.ISK.buy'
},
BTCJPY: {
url: 'https://blockchain.info/ticker',
path: '$.JPY.buy'
},
BTCKRW: {
url: 'https://blockchain.info/ticker',
path: '$.KRW.buy'
},
BTCNZD: {
url: 'https://blockchain.info/ticker',
path: '$.NZD.buy'
},
BTCPLN: {
url: 'https://blockchain.info/ticker',
path: '$.PLN.buy'
},
BTCRUB: {
url: 'https://blockchain.info/ticker',
path: '$.RUB.buy'
},
BTCSEK: {
url: 'https://blockchain.info/ticker',
path: '$.SEK.buy'
},
BTCSGD: {
url: 'https://blockchain.info/ticker',
path: '$.SGD.buy'
},
BTCTHB: {
url: 'https://blockchain.info/ticker',
path: '$.THB.buy'
},
BTCTWD: {
url: 'https://blockchain.info/ticker',
path: '$.TWD.buy'
},
BTCIDR: {
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]',
// refresh rate in milliseconds to retrieve a new price (default to 10 minutes)
refreshTime: 100000
};
var words = suffix
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
});
var currency = words.length > 0 ? words[0].toUpperCase() : options.defaultCurrency;
var amount = words.length > 1 ? parseFloat(words[1], 10) : 1;
var showHelp = isNaN(amount) || Object.keys(options.currencies).indexOf(currency) === -1;
// store the last retrieved rate
var cachedRates = {};
var command = '!price';
var currencies = Object.keys(options.currencies);
for (var i = 0; i < currencies.length; i++) {
cachedRates[currencies[i]] = {
rate: 0,
time: null
};
}
if (showHelp) {
doHelp(bot, msg, suffix);
} else {
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
return;
}
doSteps(bot, currency, amount);
}
function doHelp(bot, msg, suffix) {
if (!hasPriceBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to price bot.');
return;
}
var message =
'**' +
command +
'**: show the price of 1 LBC in ' +
options.defaultCurrency +
'\n' +
'**' +
command +
' help**: this message\n' +
'**' +
command +
' 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*, *myr*, *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) + '_';
}
function doSteps(bot, currency, amount) {
var option = options.currencies[currency];
var shouldReload = true;
if (cachedRates[currency]) {
var cache = cachedRates[currency];
shouldReload = cache.time === null || moment().diff(cache.time) >= options.refreshTime;
if (!shouldReload) {
var message = formatMessage(amount, cache, option);
msg.channel.send(message);
}
}
if (shouldReload) {
// copy the steps array
var steps = [];
for (var i = 0; i < option.steps.length; i++) {
steps.push(option.steps[i]);
}
processSteps(bot, currency, 0, amount, steps, option);
}
}
function processSteps(bot, currency, rate, amount, steps, option) {
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.');
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.');
return;
}
var pairRate = 0;
try {
pairRate = jp.query(JSON.parse(body), pair.path);
if (Array.isArray(pairRate) && pairRate.length > 0) {
pairRate = pairRate[0];
}
} catch (ignored) {
// invalid response or pair rate
}
if (pairRate > 0) {
rate = rate === 0 ? pairRate : rate * pairRate;
steps.shift();
if (steps.length > 0) {
processSteps(bot, currency, rate, amount, steps, option);
return;
}
// final step, cache and then response
var result = {
rate: rate,
time: moment()
};
cachedRates[currency] = result;
msg.channel.send(formatMessage(amount, result, option));
} else {
msg.channel.send('The rate returned for the ' + pairName + ' pair was invalid.');
}
});
}
}
}
};

View file

@ -1,43 +0,0 @@
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
];
exports.purge = {
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!");
return;
}
if (hasPerms(msg)) {
if (!suffix) {
var newamount = '2';
} else {
var amount = Number(suffix);
var adding = 1;
var newamount = amount + adding;
}
let messagecount = newamount.toString();
msg.channel
.fetchMessages({
limit: messagecount
})
.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);
})
.catch(err => {
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));
}
}
};

View file

@ -1,170 +0,0 @@
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
];
exports.releasenotes = {
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'
};
// Configure the request
var options = {
url: 'https://api.github.com/repos/lbryio/lbry-app/releases/latest',
method: 'GET',
headers: headers
};
// Start the request
request(options, function(error, response, body) {
releasemessage = JSON.parse(body).body;
releasename = JSON.parse(body).name;
releasedate = JSON.parse(body).published_at;
releaseurl = JSON.parse(body).html_url;
if (releasemessage.length < 2000) {
message = {
embed: {
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'
},
footer: {
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
if (inPrivate(msg)) {
msg.channel.send(message);
return;
}
if (hasPerms(msg) && suffix === 'post') {
bot.channels.get(ChannelID).send(message);
} else {
msg.channel.send(msg.author + ' Release notes sent via DM');
msg.author.send(message);
}
} else {
message = releasemessage
.trim()
.split('###')
.filter(function(n) {
return n !== '';
});
releasemessage1 = message[0];
releasemessage2 = message[1];
releasemessage3 = message[2];
releasemessage4 = message[3];
releasemessage5 = message[4];
message1 = {
embed: {
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'
},
footer: {
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
message2 = {
embed: {
description: releasemessage2,
color: 7976557,
timestamp: releasedate,
author: {
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 '
}
}
};
message3 = {
embed: {
description: releasemessage3,
color: 7976557,
timestamp: releasedate,
author: {
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 '
}
}
};
message4 = {
embed: {
description: releasemessage4,
color: 7976557,
timestamp: releasedate,
author: {
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 '
}
}
};
message5 = {
embed: {
description: releasemessage5,
color: 7976557,
timestamp: releasedate,
author: {
icon_url: 'http://www.pngall.com/wp-content/uploads/2016/04/Github-PNG-Image.png'
},
footer: {
icon_url: 'https://i.imgur.com/yWf5USu.png',
text: 'Lbry-app Updated '
}
}
};
if (inPrivate(msg)) {
msg.channel.send(message1);
msg.channel.send(message2);
msg.channel.send(message3);
msg.channel.send(message4);
msg.channel.send(message5);
return;
}
if (hasPerms(msg) && suffix === 'post') {
bot.channels.get(ChannelID).send(message1);
bot.channels.get(ChannelID).send(message2);
bot.channels.get(ChannelID).send(message3);
bot.channels.get(ChannelID).send(message4);
bot.channels.get(ChannelID).send(message5);
} else {
msg.channel.send(msg.author + ' Release notes sent via DM');
msg.author.send(message1);
msg.author.send(message2);
msg.author.send(message3);
msg.author.send(message4);
msg.author.send(message5);
}
}
});
}
};

View file

@ -1,21 +0,0 @@
/*exports.commands = [
"remind" // command that is in this file, every command needs it own export as shown below
]
exports.custom = [
"checkReminders"
]
exports.remind = {
usage: "<time> <message>",
description: 'description of command',
process: async function(bot,msg,suffix){
console.log(suffix);
// Here the bot,msg and suffix is avaible, this function can be async if needed.
}
}
exports.checkReminders = function(bot) {
// Other functions that needs to be ran once on bootup!
// For example a timed function and or some init stuff..
}*/

View file

@ -1,122 +0,0 @@
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'
];
exports.addrole = {
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.
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.
if (rolelist.allowedroles.includes(suffix)) {
// Checks if the role even exists in the discord server
if (newrole !== null) {
// Checks if the member has the role that they are trying to add
if (!msg.member.roles.find('name', suffix)) {
msg.member.addRole(newrole).then(msg.channel.send(msg.member + ' has been added to the ' + suffix + ' role!'));
if (rolelist.baserole !== ' ') {
if (baserole !== null) {
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 + " Role doesn't exist. Please add that role first!");
}
}
} else {
msg.channel.send('It seems that you already have that role! Try removing it first with the ' + botconfig.prefix + 'delrole command!');
}
} else {
msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!');
}
} else {
msg.channel.send("That role isn't one you can add yourself 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!');
}
}
};
exports.delrole = {
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);
// 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.
if (rolelist.allowedroles.includes(suffix)) {
// 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!'));
} else {
msg.channel.send("You don't seem to have that role! Try adding it first with the " + botconfig.prefix + 'addrole command!');
}
} else {
msg.channel.send('The role ' + '`' + suffix + '`' + ' does not exist!');
}
} else {
msg.channel.send("That role isn't one you can add yourself 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!');
}
}
};
exports.roles = {
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!',
fields: [
{
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)
}
}
});
//msg.channel.send(JSON.stringify(rolelist.allowedroles));
}
};
function buildRoleString(roles) {
let str = '';
for (let i = 0; i < roles.length; i++) {
str += '`' + roles[i] + '`' + '\n';
}
return str;
}

View file

@ -1,124 +0,0 @@
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;
/**
* Add simple spam protection to your discord server.
* @param {Bot} bot - The discord.js CLient/bot
* @param {object} options - Optional (Custom configuarion options)
* @return {[type]} [description]
*/
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 maxDuplicatesWarning = 5;
const maxDuplicatesBan = 10;
bot.on('message', msg => {
if (inPrivate(msg) || msg.author.bot || hasPerms(msg) || hasExcludedSpamChannels(msg) || hasExcludedSpamUsers(msg)) {
return;
}
if (msg.author.id != bot.user.id) {
let now = Math.floor(Date.now());
authors.push({
time: now,
author: msg.author.id
});
messagelog.push({
message: msg.content,
author: msg.author.id
});
// 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) {
msgMatch++;
}
}
// Check matched count
if (msgMatch == maxDuplicatesWarning && !warned.includes(msg.author.id)) {
warn(msg, msg.author.id);
}
if (msgMatch == maxDuplicatesBan && !banned.includes(msg.author.id)) {
ban(msg, msg.author.id);
}
matched = 0;
for (let i = 0; i < authors.length; i++) {
if (authors[i].time > now - interval) {
matched++;
if (matched == warnBuffer && !warned.includes(msg.author.id)) {
warn(msg, msg.author.id);
} else if (matched == maxBuffer) {
if (!banned.includes(msg.author.id)) {
ban(msg, msg.author.id);
}
}
} else if (authors[i].time < now - interval) {
authors.splice(i);
warned.splice(warned.indexOf(authors[i]));
banned.splice(warned.indexOf(authors[i]));
}
if (messagelog.length >= 200) {
messagelog.shift();
}
}
}
});
/**
* Warn a user
* @param {Object} msg
* @param {string} userid userid
*/
function warn(msg, userid) {
warned.push(msg.author.id);
msg.channel.send(msg.author + ' ' + warningMessage);
}
/**
* Ban a user by the user id
* @param {Object} msg
* @param {string} userid userid
* @return {boolean} True or False
*/
function ban(msg, userid) {
for (let i = 0; i < messagelog.length; i++) {
if (messagelog[i].author == msg.author.id) {
messagelog.splice(i);
}
}
banned.push(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);
return true;
})
.catch(() => {
msg.channel.send('insufficient permission to kick ' + msg.author + ' for spamming.');
return false;
});
}
}
};

View file

@ -1,248 +0,0 @@
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';
//outputs response from speech, very bulk reply
let ResponseDebug = 'false';
exports.commands = [
'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',
process: function(bot, msg, suffix) {
if (!hasSpeechBotChannels(msg) && !inPrivate(msg)) {
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to speech bot.');
return;
}
var command = '!speech';
words = suffix
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
});
var imagename = words[0];
//check if image name is help, if it is then do help message
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');
msg.channel.send(message);
doHelp(bot, msg, suffix);
return;
} else {
var message = '`no name provided`';
msg.channel.send(message);
doHelp(bot, msg, suffix);
return;
}
}
//set second word to url
var filepath = words[1];
//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');
msg.channel.send(message);
return;
} else {
var message = '`no url provided, fetching image from:`\n' + 'https://spee.ch/' + imagename;
msg.channel.send(message);
return;
}
}
//prepare url for other uses
//we will just set filepath to url to be safe
var url = filepath;
//parse first 4 letters of url should be http
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);
msg.channel.send(message);
return;
} else {
var message = '`error not a valid url, please start with http or https`';
msg.channel.send(message);
return;
}
}
//function to check if url is an image
var isUriImage = function(uri) {
//make sure we remove any nasty GET params
uri = uri.split('?')[0];
//moving on, split the uri into parts that had dots before them
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'];
//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;
} else {
return false;
}
};
//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);
msg.channel.send(message);
return;
} else {
var message = '`error not a valid image url, be sure the link includes a file type`';
msg.channel.send(message);
return;
}
}
//set third word to nsfw, with it being an optional functionality
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';
} else {
eighteen = 'yes';
}
//prepare url for wget
var source = url;
//parse the filename to use to save file
filepath = source.split('/').pop();
//set proper directory for downloading image
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;
//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`';
msg.channel.send(message);
return;
} else {
var message = '`error url could not be reached`';
msg.channel.send(message);
return;
}
});
download.on('end', output => {
//if no errors and file ready -> do the request
output && doSteps(bot, imagename, url, eighteen);
});
}
//send help message
function doHelp(bot, msg, suffix) {
msg.channel.send({
embed: {
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`',
color: 7976557,
author: {
name: 'Speech Bot Help',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
});
}
//send post request to speech
function doSteps(bot, imagename, url, eighteen) {
request.post(
//url to send post request
'https://spee.ch/api/publish',
//json payload
{
json: {
name: imagename,
file: fullpath,
nsfw: eighteen
}
},
//get response from server
function(error, response, body) {
//output response if ResponseDebug set to true
if (ResponseDebug === 'true') {
console.log(response);
console.log(error);
console.log(body.success);
console.log(body.message);
}
//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';
msg.channel.send(message);
return;
} else {
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';
msg.channel.send(message);
return;
} else {
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 + '"');
msg.channel.send(message);
}
);
}
}
};

View file

@ -1,160 +0,0 @@
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
];
exports.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/?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');
} 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 });
}
});
}
});
}
});
function parse_obj(obj) {
var array = [];
var prop;
for (prop in obj) {
if (obj.hasOwnProperty(prop)) {
var key = parseInt(prop, 10);
var value = obj[prop];
if (typeof value == 'object') {
value = parse_obj(value);
}
array[key] = value;
}
}
return array;
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
}
};

View file

@ -1,35 +0,0 @@
'use strict';
//let config = require("config");
//let rolelist = config.get("rolelist");
const Discord = require('discord.js');
let initialized = false;
let discordBot = null;
module.exports = {
init: init
};
function init(discordBot_) {
if (initialized) {
throw new Error('init was already called once');
}
discordBot = discordBot_;
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);
}
};

View file

@ -1,9 +0,0 @@
'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',
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,223 +0,0 @@
let hasPerms = require('../helpers.js').hasPerms;
let inPrivate = require('../helpers.js').inPrivate;
exports.custom = ['onUserJoin'];
exports.onUserJoin = function(bot) {
bot.on('guildMemberAdd', member => {
member.send({
embed: {
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',
color: 7976557,
author: {
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',
color: 7976557,
author: {
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',
color: 7976557,
author: {
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!*',
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',
color: 7976557,
author: {
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)!*',
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',
color: 7976557,
author: {
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?!*',
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',
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'
}
}
}).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
];
exports.welcome = {
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');
return;
}
if (suffix == '') {
msg.channel.send('no user defined');
return;
}
if (!hasPerms(msg)) {
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!*',
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',
color: 7976557,
author: {
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',
color: 7976557,
author: {
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',
color: 7976557,
author: {
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!*',
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',
color: 7976557,
author: {
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)!*',
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',
color: 7976557,
author: {
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?!*',
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',
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'
}
}
}).catch(function(error) {console.log('could not send dm')});
}
};

View file

@ -1,47 +0,0 @@
'use strict';
const fs = require('fs'),
path = require('path');
function getPlugins(srcpath) {
return fs.readdirSync(srcpath);
}
let plugin_directory = path.join(__dirname, 'modules');
let plugins = getPlugins(plugin_directory);
exports.init = function init() {
load_plugins();
};
function load_plugins() {
const dbot = require('./bot.js');
let commandCount = 0;
let otherFunc = 0;
for (let i = 0; i < plugins.length; i++) {
let plugin;
try {
plugin = require(`${plugin_directory}/${plugins[i]}`);
} catch (err) {
console.log(`Improper setup of the '${plugins[i]}' plugin. : ${err}`);
}
if (plugin) {
if ('commands' in plugin) {
for (let j = 0; j < plugin.commands.length; j++) {
if (plugin.commands[j] in plugin) {
dbot.addCommand(plugin.commands[j], plugin[plugin.commands[j]]);
commandCount++;
}
}
}
if ('custom' in plugin) {
for (let j = 0; j < plugin.custom.length; j++) {
if (plugin.custom[j] in plugin) {
dbot.addCustomFunc(plugin[plugin.custom[j]]);
otherFunc++;
}
}
}
}
}
console.log(`Loaded ${dbot.commandCount()} chat commands and ${otherFunc} custom functions.`);
}

3102
package-lock.json generated

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB