From 1bbc77434a26b609d691a3c7ec5f1e1c682389b2 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Nov 2020 15:40:49 +0100 Subject: [PATCH] Better link detection Signed-off-by: loicbersier --- commands/general/tweet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/general/tweet.js b/commands/general/tweet.js index cdfe68ab..5d41b667 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -33,7 +33,7 @@ class tweetCommand extends Command { async exec(message, args) { if (args.text) { // Very simple link detection - if (args.text.includes('http') && !args.text.includes('twitter.com')) return message.channel.send('You may not tweet links outside of twitter.com'); + if (new RegExp('([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?').test(args.text) && !args.text.includes('twitter.com')) return message.channel.send('You may not tweet links outside of twitter.com'); // Do not allow discord invites if (args.text.includes('discord.gg') || args.text.includes('discord.com/invite/')) return message.channel.send('No discord invite allowed.'); }