Fixed a problem with the lbrylinker not working on - chars.

This commit is contained in:
filipnyquist 2018-07-17 11:40:10 +02:00
parent a3de66c2ac
commit ece3da11f8
5 changed files with 285 additions and 277 deletions

View file

@ -13,9 +13,9 @@ const supportbot = require('./modules/supportbot.js');
let aliases;
try {
aliases = require("./alias.json");
aliases = require('./alias.json');
} catch (e) {
console.log("No aliases defined")
console.log('No aliases defined');
//No aliases defined
aliases = {
test: {
@ -44,9 +44,7 @@ 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);
bot.user.setActivity(config.prefix + 'help', { type: 'LISTENING' }).catch(console.error);
//initialize the claimbot (content bot)
claimbot.init(bot);
@ -76,16 +74,15 @@ function checkMessageForCommand(msg, isEdit) {
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 +
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!'
)
);
.then(msg.channel.send('Please set your Discord Presence to Online to talk to the Bot!'));
return;
});
}

View file

@ -1,88 +1,44 @@
let inPrivate = require('../helpers.js').inPrivate;
let responseDebug = false;
let { RichEmbed } = require('discord.js');
exports.custom = [
'lbrylink' //change this to your function name
];
exports.lbrylink = function(bot, msg, suffix) {
exports.lbrylink = async function(bot, msg, suffix) {
bot.on('message', msg => {
if (inPrivate(msg)) {
return;
}
if (msg.content.includes('lbry://')) {
//Extract URL from Message
let newURL = msg.content
.replace('lbry://', 'https://open.lbry.io/')
try {
// Extract the URL(s).
const urls = msg.content
.replace(new RegExp("(lbry:\\/\\/)", "g"), "https://open.lbry.io/")
.match(/\bhttps?:\/\/\S+/gi)
.toString();
if (responseDebug) {
console.log('___________________________');
console.log('newURL = ' + newURL);
.filter(url => url !== "https://open.lbry.io/");
const cleanURLs = [];
for (const i in urls) {
// Check if Username Was Supplied
const user = urls[i].match("<@.*>");
if (user) {
const { username } = msg.mentions.users.get(user[0].slice(2, -1));
urls[i] = urls[i].replace(user[0], `@${username}`);
}
//Check if just lbry:// was supplied
if (newURL == 'https://open.lbry.io/') {
return;
// Push clean URLs to the array.
cleanURLs.push(urls[i]);
}
//Check if Username Was Supplied
if (newURL.includes('>')) {
//Get rid of ID from message
let parseID = newURL.split('>').pop();
let newURL = 'https://open.lbry.io' + parseID;
if (responseDebug) {
console.log('Username Provided!');
console.log('parseID = ' + parseID);
console.log('newURL = ' + newURL);
if (cleanURLs.length < 1) return;
const linkEmbed = new RichEmbed();
linkEmbed
.setAuthor("LBRY Linker")
.setDescription("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:")
.setColor(7976557);
cleanURLs.forEach(url => linkEmbed.addField("Open with LBRY:", url, true));
return msg.embed(linkEmbed);
} catch (e) {
console.log(e);
msg.channel.send("Something went wrong when trying to run the lbrylinker, contact a moderator.");
}
//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`
let parseID = parseID.split('/').pop();
let 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.replace(/[^0-9a-z#./:]/gi,''),
color: 7976557,
author: {
name: 'LBRY Linker',
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
};
msg.channel.send({ embed });
}
});
};

View file

@ -4,7 +4,8 @@ let inPrivate = require('../helpers.js').inPrivate;
exports.custom = ['onUserJoin'];
exports.onUserJoin = function(bot) {
bot.on('guildMemberAdd', member => {
member.send({
member
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
@ -19,12 +20,17 @@ exports.onUserJoin = function(bot) {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {
bot.channels.get('369896313082478594').send(member +
})
.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 <#431211007050776577> and see the Wunderbot and tipbot commands by typing `!help` in <#369896313082478594>'
)
);
});
member.send({
member
.send({
embed: {
description:
'1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n' +
@ -40,8 +46,12 @@ exports.onUserJoin = function(bot) {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
member.send({
})
.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' +
@ -57,8 +67,12 @@ exports.onUserJoin = function(bot) {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
member.send({
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
@ -71,8 +85,12 @@ exports.onUserJoin = function(bot) {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
member.send({
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
title: '*Click here to see all LBRY Frequently Asked Questions (FAQ)!*',
description:
@ -85,8 +103,12 @@ exports.onUserJoin = function(bot) {
icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
member.send({
})
.catch(function(error) {
console.log('could not send dm');
});
member
.send({
embed: {
title: '*Have you checked out spee.ch yet?!*',
description:
@ -99,7 +121,10 @@ exports.onUserJoin = function(bot) {
icon_url: 'http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
})
.catch(function(error) {
console.log('could not send dm');
});
});
};
@ -123,7 +148,9 @@ exports.welcome = {
msg.channel.send('You Dont Have Permission To Use This Command!');
return;
}
msg.mentions.members.first().send({
msg.mentions.members
.first()
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
@ -138,12 +165,16 @@ exports.welcome = {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {
msg.channel.send(msg.mentions.members.first() +
})
.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({
msg.mentions.members
.first()
.send({
embed: {
description:
'1. Be respectful to other community members. Harrasment and vulgarity will not be tolerated \n' +
@ -159,8 +190,13 @@ exports.welcome = {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
msg.mentions.members.first().send({
})
.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' +
@ -176,8 +212,13 @@ exports.welcome = {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
msg.mentions.members.first().send({
})
.catch(function(error) {
console.log('could not send dm');
});
msg.mentions.members
.first()
.send({
embed: {
title: '*Click here for more info about LBRY!*',
description:
@ -190,8 +231,13 @@ exports.welcome = {
icon_url: 'https://i.imgur.com/yWf5USu.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
msg.mentions.members.first().send({
})
.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:
@ -204,8 +250,12 @@ exports.welcome = {
icon_url: 'https://spee.ch/8/Id5Qoc3w.png'
}
}
}).catch(console.error).then(console.log('could not send dm'));
msg.mentions.members.first().send({
})
.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:
@ -218,6 +268,9 @@ exports.welcome = {
icon_url: 'http://www.pd4pic.com/images/flag-green-blue-purple-indigo-bars-background.png'
}
}
}).catch(function(error) {console.log('could not send dm')});
})
.catch(function(error) {
console.log('could not send dm');
});
}
};

View file

@ -183,7 +183,8 @@
"bundle": {
"url": "",
"title": "",
"description": ":warning: Hey, glad to see you love **LBRY** so much, but for the safety of our users we ask that you avoid using **Discord names** that include the word **LBRY**, names of **LBRY staff**, names of other **LBRY members** on the this server or any name that could be considered **deceptive**. This is to prevent impersonation and scams.",
"description":
":warning: Hey, glad to see you love **LBRY** so much, but for the safety of our users we ask that you avoid using **Discord names** that include the word **LBRY**, names of **LBRY staff**, names of other **LBRY members** on the this server or any name that could be considered **deceptive**. This is to prevent impersonation and scams.",
"color": 7976557,
"author": {
"name": "Discord Username",
@ -800,7 +801,8 @@
"bundle": {
"url": "",
"title": "",
"description": "Type `!tip help` or `!tips` to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). <#369896313082478594> should be used to talk to bots in order to avoid spamming other channels. \nRead our [Tipbot FAQ](https://lbry.io/faq/tipbot-discord) on how use the LBRY Discord Tipbot",
"description":
"Type `!tip help` or `!tips` to interact with our Tipbot which can be used to send and receive LBRY Credits (LBC). <#369896313082478594> should be used to talk to bots in order to avoid spamming other channels. \nRead our [Tipbot FAQ](https://lbry.io/faq/tipbot-discord) on how use the LBRY Discord Tipbot",
"color": 7976557,
"author": {
"name": "Tipbot Help Message",