Compare commits
No commits in common. "master" and "fix-priv-roletip" have entirely different histories.
master
...
fix-priv-r
13 changed files with 4265 additions and 407 deletions
|
@ -1,31 +0,0 @@
|
||||||
{
|
|
||||||
"env": {
|
|
||||||
"commonjs": true,
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended"
|
|
||||||
],
|
|
||||||
"globals": {},
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2020,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"@typescript-eslint"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"quotes": [
|
|
||||||
"warn",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
"warn",
|
|
||||||
"always"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"deepscan.enable": true
|
|
||||||
}
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018-2020 LBRY <filip@lbry.com>
|
Copyright (c) 2018 LBRY <filip@lbry.io>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
60
README.md
60
README.md
|
@ -1,4 +1,4 @@
|
||||||
# Bot for [LBRY's Discord](https://chat.lbry.com)
|
# Bot for [LBRY's Discord](https://discord.gg/tgnNHf5)
|
||||||
(This README will be updated along with bot updates)
|
(This README will be updated along with bot updates)
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
|
@ -9,63 +9,17 @@ Features:
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- node > 12.0.x
|
- node > 8.0.0
|
||||||
- yarn
|
- npm > 0.12.x
|
||||||
- node-typescript
|
|
||||||
- LBRYCrd 0.17.x (https://github.com/lbryio/lbrycrd/)
|
|
||||||
|
|
||||||
## Install the prerequisites
|
|
||||||
### NodeJS & Typescript
|
|
||||||
|
|
||||||
Install NodeJS v12 for the Operating system you are running.
|
|
||||||
[NodeJS Documentation link](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions-enterprise-linux-fedora-and-snap-packages)
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt install nodejs-typescript
|
|
||||||
```
|
|
||||||
### Install Yarn Globally
|
|
||||||
```
|
|
||||||
sudo npm install -g yarn
|
|
||||||
```
|
|
||||||
### Download LBRYCRD
|
|
||||||
Download the latest 0.17 release of LBRYcrd from the [Github](https://github.com/lbryio/lbrycrd/releases)
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Install LBRYCrd
|
Create a bot and get the bot's API Token: https://discordapp.com/developers/applications/me
|
||||||
```
|
|
||||||
$ unzip ~/lbrycrd-linux.zip
|
|
||||||
```
|
|
||||||
Follow the instructions on the LBRYCrds GitHub Repository to create a lbrycrd.conf and remember the username and password.
|
|
||||||
|
|
||||||
Start LBRYCrd
|
Edit and rename default.json.example in /config, then run:
|
||||||
```
|
|
||||||
./lbrycrdd -server -daemon
|
|
||||||
```
|
|
||||||
|
|
||||||
Create a bot and get the bot's API Token: https://discordapp.com/developers/applications/me - ![](https://i.imgur.com/gM8EpJe.png)
|
|
||||||
|
|
||||||
Make sure the bot has "bot" flags in OAuth2
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cd lbry-tipbot/config
|
npm install
|
||||||
|
node bot.js
|
||||||
```
|
```
|
||||||
Then
|
|
||||||
```
|
|
||||||
$ vim default.json.example
|
|
||||||
```
|
|
||||||
Input your bot's token, the channel ID for your bot command channel, and the username & password for LBRYCrd
|
|
||||||
. Then, Rename the configuration file to "default.json" with
|
|
||||||
|
|
||||||
```
|
|
||||||
$ mv default.json.example default.json
|
|
||||||
```
|
|
||||||
|
|
||||||
Then run yarn install from within lbry-tipbot directory
|
|
||||||
```
|
|
||||||
yarn install
|
|
||||||
yarn start
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
[MIT](https://github.com/lbryio/lbry-tipbot/blob/master/LICENSE)
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
import Discord from 'discord.js';
|
'use strict';
|
||||||
import config from 'config';
|
|
||||||
import { BotConfig } from './typings';
|
|
||||||
|
|
||||||
let botConfig: BotConfig = config.get('bot');
|
// Load up libraries
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
// Load config!
|
||||||
|
let config = require('config');
|
||||||
|
let botConfig = config.get('bot');
|
||||||
let commands = {};
|
let commands = {};
|
||||||
|
|
||||||
const bot = new Discord.Client();
|
const bot = new Discord.Client();
|
||||||
|
|
||||||
bot.on('ready', () => {
|
bot.on('ready', function() {
|
||||||
console.log(`Logged in! Serving in ${bot.guilds.cache.size} servers`);
|
console.log(`Logged in! Serving in ${bot.guilds.array().length} servers`);
|
||||||
require('./plugins.js').init();
|
require('./plugins.js').init();
|
||||||
console.log(`type ${botConfig.prefix}help in Discord for a commands list.`);
|
console.log(`type ${botConfig.prefix}help in Discord for a commands list.`);
|
||||||
bot.user.setActivity(botConfig.prefix + 'tip');
|
bot.user.setActivity(botConfig.prefix + 'tip');
|
||||||
|
@ -19,16 +21,16 @@ bot.on('disconnected', function() {
|
||||||
process.exit(1); //exit node.js with an error
|
process.exit(1); //exit node.js with an error
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.on('message', msg => {
|
function checkMessageForCommand(msg) {
|
||||||
//check if message is a command
|
//check if message is a command
|
||||||
if (msg.author.id !== bot.user.id && msg.content.startsWith(botConfig.prefix)) {
|
if (msg.author.id !== bot.user.id && msg.content.startsWith(botConfig.prefix)) {
|
||||||
console.log(`treating ${msg.content} from ${msg.author} as command`);
|
console.log(`treating ${msg.content} from ${msg.author} as command`);
|
||||||
let cmdTxt = msg.content.split(/ +/)[0].substring(botConfig.prefix.length);
|
let cmdTxt = msg.content.split(' ')[0].substring(botConfig.prefix.length);
|
||||||
let suffix = msg.content.substring(cmdTxt.length + botConfig.prefix.length + 1); //add one for the ! and one for the space
|
let suffix = msg.content.substring(cmdTxt.length + botConfig.prefix.length + 1); //add one for the ! and one for the space
|
||||||
if (msg.mentions.has(bot.user)) {
|
if (msg.isMentioned(bot.user)) {
|
||||||
try {
|
try {
|
||||||
cmdTxt = msg.content.split(/ +/)[1];
|
cmdTxt = msg.content.split(' ')[1];
|
||||||
suffix = msg.content.substring(bot.user.toString().length + cmdTxt.length + botConfig.prefix.length + 1);
|
suffix = msg.content.substring(bot.user.mention().length + cmdTxt.length + botConfig.prefix.length + 1);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//no command
|
//no command
|
||||||
return msg.channel.send('Yes?');
|
return msg.channel.send('Yes?');
|
||||||
|
@ -53,8 +55,14 @@ bot.on('message', msg => {
|
||||||
if (msg.author === bot.user) {
|
if (msg.author === bot.user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg.author !== bot.user && msg.isMentioned(bot.user)) {
|
||||||
|
msg.channel.send('yes?'); //using a mention here can lead to looping
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
bot.on('message', msg => checkMessageForCommand(msg));
|
||||||
|
|
||||||
exports.addCommand = function(commandName, commandObject) {
|
exports.addCommand = function(commandName, commandObject) {
|
||||||
try {
|
try {
|
|
@ -1,10 +1,11 @@
|
||||||
import { LBRYCrdConfig } from '../typings';
|
'use strict';
|
||||||
import config from 'config';
|
|
||||||
const Bitcoin = require('bitcoin');
|
|
||||||
|
|
||||||
let spamchannel: string = config.get('sandboxchannel');
|
const bitcoin = require('bitcoin');
|
||||||
let lbrycrdConfig: LBRYCrdConfig = config.get('lbrycrd');
|
let config = require('config');
|
||||||
const lbry = new Bitcoin.Client(lbrycrdConfig);
|
let spamchannel = config.get('sandboxchannel');
|
||||||
|
let regex = require('regex');
|
||||||
|
let lbrycrdConfig = config.get('lbrycrd');
|
||||||
|
const lbry = new bitcoin.Client(lbrycrdConfig);
|
||||||
const helpmsg = {
|
const helpmsg = {
|
||||||
embed: {
|
embed: {
|
||||||
description:
|
description:
|
||||||
|
@ -12,18 +13,19 @@ const helpmsg = {
|
||||||
'**Balance**: `!tip balance`\n' +
|
'**Balance**: `!tip balance`\n' +
|
||||||
'**Deposit Address**: `!tip deposit`\n' +
|
'**Deposit Address**: `!tip deposit`\n' +
|
||||||
'**Withdraw**: `!tip withdraw <address> <amount>`\n' +
|
'**Withdraw**: `!tip withdraw <address> <amount>`\n' +
|
||||||
'**Private Tip**: `!tip private <user> <amount>`\n\n' +
|
'**Private Tip**: `!privatetip <user> <amount>`\n\n' +
|
||||||
'__**ROLE TIPS**__ Use this to tip everyone in a role.\n\n' +
|
'__**ROLE TIPS**__ Use this to tip everyone in a role.\n\n' +
|
||||||
'**Role Tip**: `!roletip <role> <amount>`\n' +
|
'**Role Tip**: `!roletip <role> <amount>`\n' +
|
||||||
'**Private Role Tip**: `!privatetip <role> <amount>`\n\n' +
|
'**Private Role Tip**: `!privatetip <role> <amount>`\n\n' +
|
||||||
'__**MULTI TIPS**__ Use this to tip multiple people at once.\n\n' +
|
'__**MULTI TIPS**__ Use this to tip multiple people at once\n\n' +
|
||||||
'**Multi Tip**: `!multitip <user> <user> <amount>`\n' +
|
'**Multi Tip**: `!multitip <user> <user> <amount>`\n' +
|
||||||
'**Private Multi Tip** `!multitip private <user> <user> <amount>`\n' +
|
'**Private Multi Tip** `!multitip private <user> <user> <amount>`\n' +
|
||||||
'**Note**: Multi tips can contain any amount of users to tip.\n\n' +
|
'**Note**: Multi tips can contain any amount of users to tip.\n\n' +
|
||||||
'__**FURTHER INFORMATION**__\n\n' +
|
'__**FURTHER INFORMATION**__\n\n' +
|
||||||
'**Help**: `!tip help` *Get this message.\n' +
|
'**Help**: `!tip help` *Get this message.\n' +
|
||||||
'Read our [Tipbot FAQ](<https://lbry.com/faq/tipbot-discord>) for more details',
|
'Read our [Tipbot FAQ](https://lbry.io/faq/tipbot-discord) for a more details',
|
||||||
color: 1109218
|
color: 1109218,
|
||||||
|
author: { name: '!tip' }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,10 +34,10 @@ exports.tip = {
|
||||||
usage: '<subcommand>',
|
usage: '<subcommand>',
|
||||||
description: 'Tip a given user with an amount of LBC or perform wallet specific operations.',
|
description: 'Tip a given user with an amount of LBC or perform wallet specific operations.',
|
||||||
process: async function(bot, msg, suffix) {
|
process: async function(bot, msg, suffix) {
|
||||||
let tipper = msg.author.id,
|
let tipper = msg.author.id.replace('!', ''),
|
||||||
words = msg.content
|
words = msg.content
|
||||||
.trim()
|
.trim()
|
||||||
.split(/ +/)
|
.split(' ')
|
||||||
.filter(function(n) {
|
.filter(function(n) {
|
||||||
return n !== '';
|
return n !== '';
|
||||||
}),
|
}),
|
||||||
|
@ -47,7 +49,7 @@ exports.tip = {
|
||||||
privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]);
|
privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]);
|
||||||
break;
|
break;
|
||||||
case 'balance':
|
case 'balance':
|
||||||
privateOrSandboxOnly(msg, channelwarning, doBalance, [tipper]);
|
doBalance(msg, tipper);
|
||||||
break;
|
break;
|
||||||
case 'deposit':
|
case 'deposit':
|
||||||
privateOrSandboxOnly(msg, channelwarning, doDeposit, [tipper]);
|
privateOrSandboxOnly(msg, channelwarning, doDeposit, [tipper]);
|
||||||
|
@ -68,7 +70,7 @@ exports.multitip = {
|
||||||
let tipper = msg.author.id.replace('!', ''),
|
let tipper = msg.author.id.replace('!', ''),
|
||||||
words = msg.content
|
words = msg.content
|
||||||
.trim()
|
.trim()
|
||||||
.split(/ +/)
|
.split(' ')
|
||||||
.filter(function(n) {
|
.filter(function(n) {
|
||||||
return n !== '';
|
return n !== '';
|
||||||
}),
|
}),
|
||||||
|
@ -88,12 +90,12 @@ exports.multitip = {
|
||||||
|
|
||||||
exports.roletip = {
|
exports.roletip = {
|
||||||
usage: '<subcommand>',
|
usage: '<subcommand>',
|
||||||
description: 'Tip all users in a specified role an amount of LBC.',
|
description: 'Tip every user in a given role the same amount of LBC.',
|
||||||
process: async function(bot, msg, suffix) {
|
process: async function(bot, msg, suffix) {
|
||||||
let tipper = msg.author.id.replace('!', ''),
|
let tipper = msg.author.id.replace('!', ''),
|
||||||
words = msg.content
|
words = msg.content
|
||||||
.trim()
|
.trim()
|
||||||
.split(/ +/)
|
.split(' ')
|
||||||
.filter(function(n) {
|
.filter(function(n) {
|
||||||
return n !== '';
|
return n !== '';
|
||||||
}),
|
}),
|
||||||
|
@ -113,7 +115,7 @@ exports.roletip = {
|
||||||
|
|
||||||
exports.tips = {
|
exports.tips = {
|
||||||
usage: '',
|
usage: '',
|
||||||
description: 'Lists all available tipbot commands with brief descriptions for each command.',
|
description: 'Lists all available tipbot commands with brief descriptions for each one.',
|
||||||
process: async function(bot, msg, suffix) {
|
process: async function(bot, msg, suffix) {
|
||||||
msg.reply(helpmsg);
|
msg.reply(helpmsg);
|
||||||
}
|
}
|
||||||
|
@ -131,13 +133,12 @@ function doHelp(message, helpmsg) {
|
||||||
message.author.send(helpmsg);
|
message.author.send(helpmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doBalance(message, tipper) {
|
function doBalance(message, tipper) {
|
||||||
lbry.getBalance(tipper, 1, function(err, balance) {
|
lbry.getBalance(tipper, 1, function(err, balance) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
message.reply('Error getting balance.').then(message => message.delete(5000));
|
||||||
message.reply('Error getting balance.').then(message => message.delete({timeout: 5000}));
|
|
||||||
} else {
|
} else {
|
||||||
message.reply(`You have *${balance}* LBC. This may not reflect recent balance changes. Please wait a couple minutes and try again.`);
|
message.reply(`You have *${balance}* LBC`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -145,8 +146,7 @@ async function doBalance(message, tipper) {
|
||||||
function doDeposit(message, tipper) {
|
function doDeposit(message, tipper) {
|
||||||
getAddress(tipper, function(err, address) {
|
getAddress(tipper, function(err, address) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
message.reply('Error getting your deposit address.').then(message => message.delete(5000));
|
||||||
message.reply('Error getting your deposit address.').then(message => message.delete({timeout: 5000}));
|
|
||||||
} else {
|
} else {
|
||||||
message.reply(`Your address is ${address}`);
|
message.reply(`Your address is ${address}`);
|
||||||
}
|
}
|
||||||
|
@ -162,15 +162,15 @@ function doWithdraw(message, tipper, words, helpmsg) {
|
||||||
amount = getValidatedAmount(words[3]);
|
amount = getValidatedAmount(words[3]);
|
||||||
|
|
||||||
if (amount === null) {
|
if (amount === null) {
|
||||||
message.reply('Invalid amount of credits specified... Cannot withdraw credits.').then(message => message.delete({timeout: 5000}));
|
message.reply("I don't know how to withdraw that many credits...").then(message => message.delete(5000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.sendFrom(tipper, address, amount, function(err, txId) {
|
lbry.sendFrom(tipper, address, amount, function(err, txId) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return message.reply(err.message).then(message => message.delete({timeout: 5000}));
|
return message.reply(err.message).then(message => message.delete(5000));
|
||||||
}
|
}
|
||||||
message.reply(`${amount} LBC has been withdrawn to ${address}.
|
message.reply(`You withdrew ${amount} LBC to ${address}.
|
||||||
${txLink(txId)}`);
|
${txLink(txId)}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -190,13 +190,13 @@ function doTip(bot, message, tipper, words, helpmsg, MultiorRole) {
|
||||||
let amount = getValidatedAmount(words[amountOffset]);
|
let amount = getValidatedAmount(words[amountOffset]);
|
||||||
|
|
||||||
if (amount === null) {
|
if (amount === null) {
|
||||||
return message.reply('Invalid amount of credits specified...').then(message => message.delete({timeout: 5000}));
|
return message.reply("I don't know how to tip that many credits...").then(message => message.delete(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.mentions.users.first() && message.mentions.users.first().id) {
|
if (message.mentions.users.first() && message.mentions.users.first().id) {
|
||||||
return sendLBC(bot, message, tipper, message.mentions.users.first().id.replace('!', ''), amount, prv, MultiorRole);
|
return sendLBC(bot, message, tipper, message.mentions.users.first().id.replace('!', ''), amount, prv, MultiorRole);
|
||||||
}
|
}
|
||||||
message.reply('Sorry, I could not find the user you are trying to tip...');
|
message.reply('Sorry, I could not find a user in your tip...');
|
||||||
}
|
}
|
||||||
|
|
||||||
function doMultiTip(bot, message, tipper, words, helpmsg, MultiorRole) {
|
function doMultiTip(bot, message, tipper, words, helpmsg, MultiorRole) {
|
||||||
|
@ -214,11 +214,11 @@ function doMultiTip(bot, message, tipper, words, helpmsg, MultiorRole) {
|
||||||
}
|
}
|
||||||
let [userIDs, amount] = findUserIDsAndAmount(message, words, prv);
|
let [userIDs, amount] = findUserIDsAndAmount(message, words, prv);
|
||||||
if (amount == null) {
|
if (amount == null) {
|
||||||
message.reply('Invalid amount of credits specified...').then(message => message.delete({timeout: 5000}));
|
message.reply("I don't know how to tip that many credits...").then(message => message.delete(5000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!userIDs.length) {
|
if (!userIDs) {
|
||||||
message.reply('Sorry, I could not find the user you are trying to tip...').then(message => message.delete({timeout: 5000}));
|
message.reply('Sorry, I could not find a user in your tip...').then(message => message.delete(5000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < userIDs.length; i++) {
|
for (let i = 0; i < userIDs.length; i++) {
|
||||||
|
@ -231,28 +231,28 @@ function doRoleTip(bot, message, tipper, words, helpmsg, MultiorRole) {
|
||||||
doHelp(message, helpmsg);
|
doHelp(message, helpmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let isPrivateTip = words.length >= 4 && words[1] === 'private';
|
let prv = false;
|
||||||
let amountOffset = isPrivateTip ? 3 : 2;
|
let amountOffset = 2;
|
||||||
|
if (words.length >= 4 && words[1] === 'private') {
|
||||||
|
prv = true;
|
||||||
|
amountOffset = 3;
|
||||||
|
}
|
||||||
let amount = getValidatedAmount(words[amountOffset]);
|
let amount = getValidatedAmount(words[amountOffset]);
|
||||||
if (amount === null) {
|
if (amount == null) {
|
||||||
message.reply("I don't know how to tip that amount of LBC...").then(message => message.delete({timeout: 10000}));
|
message.reply("I don't know how to tip that many LBC coins...").then(message => message.delete(10000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (message.mentions.roles.first().id) {
|
||||||
let roleToTip = message.mentions.roles.first();
|
if (message.mentions.roles.first().members.first().id) {
|
||||||
if (roleToTip !== null) {
|
let userIDs = message.mentions.roles.first().members.map(member => member.user.id.replace('!', ''));
|
||||||
let membersOfRole = roleToTip.members.keyArray();
|
for (let i = 0; i < userIDs.length; i++) {
|
||||||
if (membersOfRole.length > 0) {
|
sendLBC(bot, message, tipper, userIDs[i].toString(), amount, prv, MultiorRole);
|
||||||
let userIDs = membersOfRole.map(member => member.replace('!', ''));
|
}
|
||||||
userIDs.forEach(u => {
|
|
||||||
sendLBC(bot, message, tipper, u, amount, isPrivateTip, MultiorRole);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
return message.reply('Sorry, I could not find any users to tip in that role...').then(message => message.delete({timeout: 10000}));
|
return message.reply('Sorry, I could not find any users to tip in that role...').then(message => message.delete(10000));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return message.reply('Sorry, I could not find any roles in your tip...').then(message => message.delete({timeout: 10000}));
|
return message.reply('Sorry, I could not find any roles in your tip...').then(message => message.delete(10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,27 +278,27 @@ function findUserIDsAndAmount(message, words, prv) {
|
||||||
function sendLBC(bot, message, tipper, recipient, amount, privacyFlag, MultiorRole) {
|
function sendLBC(bot, message, tipper, recipient, amount, privacyFlag, MultiorRole) {
|
||||||
getAddress(recipient.toString(), function(err, address) {
|
getAddress(recipient.toString(), function(err, address) {
|
||||||
if (err) {
|
if (err) {
|
||||||
message.reply(err.message).then(message => message.delete({timeout: 5000}));
|
message.reply(err.message).then(message => message.delete(5000));
|
||||||
} else {
|
} else {
|
||||||
lbry.sendFrom(tipper, address, Number(amount), 1, null, null, function(err, txId) {
|
lbry.sendFrom(tipper, address, Number(amount), 1, null, null, function(err, txId) {
|
||||||
if (err) {
|
if (err) {
|
||||||
message.reply(err.message).then(message => message.delete({timeout: 5000}));
|
message.reply(err.message).then(message => message.delete(5000));
|
||||||
} else {
|
} else {
|
||||||
let tx = txLink(txId);
|
let tx = txLink(txId);
|
||||||
let msgtail = `
|
let msgtail = `
|
||||||
DM me with \`!tips\` for all available commands or read our Tipbot FAQ <https://lbry.com/faq/tipbot-discord> for more details`;
|
DM me with \`${message.content.split(' ', 1)[0]}\` for command specific instructions or with \`!tips\` for all available commands`;
|
||||||
if (privacyFlag) {
|
if (privacyFlag) {
|
||||||
let usr = message.guild.members.find('id', recipient).user;
|
let usr = message.guild.members.find('id', recipient).user;
|
||||||
let authmsg = `You have sent a private tip to @${usr.tag} with the amount of ${amount} LBC.
|
let authmsg = `You have just privately tipped @${usr.tag} ${amount} LBC.
|
||||||
${tx}${msgtail}`;
|
${tx}${msgtail}`;
|
||||||
message.author.send(authmsg);
|
message.author.send(authmsg);
|
||||||
if (message.author.id !== usr.id) {
|
if (message.author.id !== message.mentions.users.first().id) {
|
||||||
let recipientmsg = `You have just been privately tipped ${amount} LBC by @${message.author.tag}.
|
let recipientmsg = `You have just been privately tipped ${amount} LBC by @${message.author.tag}.
|
||||||
${tx}${msgtail}`;
|
${tx}${msgtail}`;
|
||||||
usr.send(recipientmsg);
|
usr.send(recipientmsg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let generalmsg = `just tipped <@${recipient}> ${amount} LBC.
|
let generalmsg = `Wubba lubba dub dub! <@${tipper}> tipped <@${recipient}> ${amount} LBC.
|
||||||
${tx}${msgtail}`;
|
${tx}${msgtail}`;
|
||||||
message.reply(generalmsg);
|
message.reply(generalmsg);
|
||||||
}
|
}
|
||||||
|
@ -307,6 +307,7 @@ ${tx}${msgtail}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddress(userId, cb) {
|
function getAddress(userId, cb) {
|
||||||
lbry.getAddressesByAccount(userId, function(err, addresses) {
|
lbry.getAddressesByAccount(userId, function(err, addresses) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -330,10 +331,13 @@ function inPrivateOrBotSandbox(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValidatedAmount(amount) {
|
function getValidatedAmount(amount) {
|
||||||
amount = amount.toLowerCase().replace('lbc', '');
|
amount = amount.trim();
|
||||||
|
if (amount.toLowerCase().endsWith('lbc')) {
|
||||||
|
amount = amount.substring(0, amount.length - 3);
|
||||||
|
}
|
||||||
return amount.match(/^[0-9]+(\.[0-9]+)?$/) ? amount : null;
|
return amount.match(/^[0-9]+(\.[0-9]+)?$/) ? amount : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function txLink(txId) {
|
function txLink(txId) {
|
||||||
return '<https://explorer.lbry.com/tx/' + txId + '>';
|
return '<https://explorer.lbry.io/tx/' + txId + '>';
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
import fs from 'fs';
|
'use strict';
|
||||||
import path from 'path';
|
|
||||||
|
const fs = require('fs'),
|
||||||
|
path = require('path');
|
||||||
|
|
||||||
function getPlugins(srcpath) {
|
function getPlugins(srcpath) {
|
||||||
return fs.readdirSync(srcpath);
|
return fs.readdirSync(srcpath);
|
||||||
|
@ -7,7 +9,7 @@ function getPlugins(srcpath) {
|
||||||
let plugin_directory = path.join(__dirname, 'modules');
|
let plugin_directory = path.join(__dirname, 'modules');
|
||||||
let plugins = getPlugins(plugin_directory);
|
let plugins = getPlugins(plugin_directory);
|
||||||
|
|
||||||
export function init() {
|
exports.init = function init() {
|
||||||
load_plugins();
|
load_plugins();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,16 +2,7 @@
|
||||||
"bot": {
|
"bot": {
|
||||||
"token": "discordbottoken",
|
"token": "discordbottoken",
|
||||||
"prefix": "!",
|
"prefix": "!",
|
||||||
"debug": true,
|
"debug": false
|
||||||
"intents": [
|
|
||||||
"guilds",
|
|
||||||
"guildEmojis",
|
|
||||||
"guildMembers",
|
|
||||||
"guildMessages",
|
|
||||||
"guildMessageReactions",
|
|
||||||
"directMessages",
|
|
||||||
"directMessageReactions"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"lbrycrd": {
|
"lbrycrd": {
|
||||||
"port": 9245,
|
"port": 9245,
|
||||||
|
|
2451
package-lock.json
generated
Normal file
2451
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
34
package.json
34
package.json
|
@ -1,33 +1,35 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"babel-cli": "^6.26.0",
|
||||||
|
"babel-preset-node8": "^1.2.0",
|
||||||
"bitcoin": "^3.0.1",
|
"bitcoin": "^3.0.1",
|
||||||
"chrono-node": "^2.1.9",
|
"chrono-node": "^1.3.5",
|
||||||
"config": "^3.3.2",
|
"config": "^1.30.0",
|
||||||
"discord.js": "^12.4.1",
|
"discord.js": "^11.3.2",
|
||||||
"jsonpath": "^1.0.2",
|
"embed-creator": "^1.2.3",
|
||||||
"moment": "^2.29.1",
|
"jsonpath": "^1.0.0",
|
||||||
"needle": "^2.5.2",
|
"moment": "^2.22.1",
|
||||||
|
"mongoose": "^5.0.17",
|
||||||
"node-config": "^0.0.2",
|
"node-config": "^0.0.2",
|
||||||
"numeral": "^2.0.6"
|
"numeral": "^2.0.6",
|
||||||
|
"regex": "^0.1.1",
|
||||||
|
"request": "^2.85.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prettier": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
|
"prettier": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
|
||||||
"build": "tsc",
|
"build": "babel bot -d dist",
|
||||||
"start": "tsc && node dist/bot.js",
|
"prod": "babel bot -d dist & node dist/bot.js",
|
||||||
"lint": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
|
"lint": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240",
|
||||||
"precommit": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240"
|
"precommit": "prettier --write '{bot,.}/**/*.{js,json}' --single-quote --print-width 240"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/config": "^0.0.36",
|
"prettier": "^1.12.1"
|
||||||
"@types/node": "^14.14.7",
|
|
||||||
"prettier": "^2.1.2",
|
|
||||||
"typescript": "latest"
|
|
||||||
},
|
},
|
||||||
"name": "lbry-tipbot",
|
"name": "lbry-tipbot",
|
||||||
"version": "0.0.5",
|
"version": "0.0.4",
|
||||||
"description": "LBRYs tipbot for Discord",
|
"description": "LBRYs tipbot for Discord",
|
||||||
"main": "dist/bot.js",
|
"main": "app.js",
|
||||||
"repository": "https://github.com/lbryio/lbry-tipbot",
|
"repository": "https://github.com/lbryio/lbry-tipbot",
|
||||||
"author": "filipnyquist <filip@lbry.com>",
|
"author": "filipnyquist <filip@lbry.io>",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
export interface Config {
|
|
||||||
bot: BotConfig;
|
|
||||||
lbrycrd: LBRYCrdConfig;
|
|
||||||
sandboxchannel: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BotConfig {
|
|
||||||
token: string;
|
|
||||||
prefix: string;
|
|
||||||
debug: boolean;
|
|
||||||
intents: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LBRYCrdConfig {
|
|
||||||
port: number;
|
|
||||||
user: string;
|
|
||||||
pass: string;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es2020",
|
|
||||||
"inlineSourceMap": true,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "dist",
|
|
||||||
"removeComments": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"paths": {
|
|
||||||
"*": ["node_modules/*"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": ["src/**/*"]
|
|
||||||
}
|
|
Loading…
Reference in a new issue