mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
Merge pull request #280 from lbryio/Coolguy3289-patch-3
Allow modular function of claimbot and ircbot
This commit is contained in:
commit
cfe2b6914d
5 changed files with 34 additions and 20 deletions
|
@ -5,7 +5,7 @@ const Discord = require('discord.js');
|
||||||
// Load config!
|
// Load config!
|
||||||
let config = require('config');
|
let config = require('config');
|
||||||
config = config.get('bot');
|
config = config.get('bot');
|
||||||
|
let genconfig = require('config');
|
||||||
//load modules
|
//load modules
|
||||||
const claimbot = require('./modules/claimbot.js');
|
const claimbot = require('./modules/claimbot.js');
|
||||||
const commandsV2 = require('./modules/commandsV2.js');
|
const commandsV2 = require('./modules/commandsV2.js');
|
||||||
|
@ -47,7 +47,9 @@ bot.on('ready', function() {
|
||||||
bot.user.setActivity(config.prefix + 'help', { type: 'LISTENING' }).catch(console.error);
|
bot.user.setActivity(config.prefix + 'help', { type: 'LISTENING' }).catch(console.error);
|
||||||
|
|
||||||
//initialize the claimbot (content bot)
|
//initialize the claimbot (content bot)
|
||||||
claimbot.init(bot);
|
if (genconfig.get('claimbot').enabled) {
|
||||||
|
claimbot.init(bot);
|
||||||
|
}
|
||||||
//initialize the commandsBot
|
//initialize the commandsBot
|
||||||
commandsV2.init(bot);
|
commandsV2.init(bot);
|
||||||
//initialize the support bot
|
//initialize the support bot
|
||||||
|
|
|
@ -15,10 +15,29 @@ function init(discordBot_) {
|
||||||
if (discordBot) {
|
if (discordBot) {
|
||||||
throw new Error('init was already called once');
|
throw new Error('init was already called once');
|
||||||
}
|
}
|
||||||
|
discordBot = discordBot_;
|
||||||
|
console.log('Activating claimbot');
|
||||||
|
discordBot.channels.get(channels[0]).send('activating claimbot');
|
||||||
|
setInterval(announceClaims, 60 * 1000);
|
||||||
|
announceClaims();
|
||||||
|
}
|
||||||
|
|
||||||
discordBot = discordBot_;
|
function announceClaims() {
|
||||||
console.log('Activating claimbot');
|
let currentBlock = lastProcessedBlock;
|
||||||
discordBot.channels.get(channels[0]).send('activating claimbot');
|
getClaimsForLastBlock()
|
||||||
|
.then(claims => {
|
||||||
|
claims.forEach(c => {
|
||||||
|
if (c.height <= lastProcessedBlock) return;
|
||||||
|
currentBlock = Math.max(currentBlock, c.height);
|
||||||
|
|
||||||
|
//filter claims that we don't want to announce
|
||||||
|
if (c.bid_state === 'Expired' || c.bid_state === 'Spent') return;
|
||||||
|
|
||||||
|
discordPost(embedFromClaim(c));
|
||||||
|
});
|
||||||
|
lastProcessedBlock = currentBlock;
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,5 +4,7 @@ const ircconfig = config.get('irc');
|
||||||
exports.custom = ['irc'];
|
exports.custom = ['irc'];
|
||||||
|
|
||||||
exports.irc = function(bot) {
|
exports.irc = function(bot) {
|
||||||
discordIRC([ircconfig]);
|
if (ircconfig.enabled) {
|
||||||
|
discordIRC([ircconfig]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -414,7 +414,7 @@
|
||||||
"icon_url": "https://spee.ch/2/pinkylbryheart.png"
|
"icon_url": "https://spee.ch/2/pinkylbryheart.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"!rewardsapproval": {
|
"!rewardsapproval": {
|
||||||
"usage": "",
|
"usage": "",
|
||||||
"description": "Rewards Approval Help Message",
|
"description": "Rewards Approval Help Message",
|
||||||
|
@ -880,8 +880,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"!status": {
|
"!status": {
|
||||||
"usage": "",
|
"usage": "",
|
||||||
"description": "LBRY Services Status",
|
"description": "LBRY Services Status",
|
||||||
"operation": "send",
|
"operation": "send",
|
||||||
|
@ -897,7 +897,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"!why": {
|
"!why": {
|
||||||
"usage": "",
|
"usage": "",
|
||||||
"description": "Why should I use LBRY?",
|
"description": "Why should I use LBRY?",
|
||||||
|
@ -914,7 +913,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"!piratebay": {
|
"!piratebay": {
|
||||||
"usage": "",
|
"usage": "",
|
||||||
"description": "Why LBRY has piratebay.com",
|
"description": "Why LBRY has piratebay.com",
|
||||||
|
|
|
@ -9,15 +9,6 @@
|
||||||
"perms": ["Moderator Team", "LBRY TEAM"], // Roles that have access to all commands.
|
"perms": ["Moderator Team", "LBRY TEAM"], // Roles that have access to all commands.
|
||||||
"logchannel": "371620338263523328" // Channel to log the bots moderation..
|
"logchannel": "371620338263523328" // Channel to log the bots moderation..
|
||||||
},
|
},
|
||||||
"lbrycrd": {
|
|
||||||
"host": "localhost",
|
|
||||||
"port": 9245,
|
|
||||||
"user": "USERHERE",
|
|
||||||
"pass": "PASSWORDHERE"
|
|
||||||
},
|
|
||||||
"mongodb": {
|
|
||||||
"url": "mongodb://localhost:27017/wunderbot"
|
|
||||||
},
|
|
||||||
"Channels": {
|
"Channels": {
|
||||||
"verification": "571001864271691805",
|
"verification": "571001864271691805",
|
||||||
"mining": "363049669636390913",
|
"mining": "363049669636390913",
|
||||||
|
@ -59,6 +50,7 @@
|
||||||
"mainchannel": "363050205043621908" // Main Stats Bot channel for directing with help message
|
"mainchannel": "363050205043621908" // Main Stats Bot channel for directing with help message
|
||||||
},
|
},
|
||||||
"claimbot": {
|
"claimbot": {
|
||||||
|
"enabled": false,
|
||||||
"channels": ["363086719391629326"]
|
"channels": ["363086719391629326"]
|
||||||
},
|
},
|
||||||
"rolelist": {
|
"rolelist": {
|
||||||
|
@ -66,6 +58,7 @@
|
||||||
"allowedroles": ["Off-Topic Chats", "Dev"]
|
"allowedroles": ["Off-Topic Chats", "Dev"]
|
||||||
},
|
},
|
||||||
"irc": {
|
"irc": {
|
||||||
|
"enabled": false,
|
||||||
"nickname": "wunderbot",
|
"nickname": "wunderbot",
|
||||||
"server": "chat.freenode.net",
|
"server": "chat.freenode.net",
|
||||||
"discordToken": "",
|
"discordToken": "",
|
||||||
|
|
Loading…
Add table
Reference in a new issue