allow invite links without the protocol

This commit is contained in:
13xforever 2018-08-19 17:32:57 +05:00 committed by Roberto Anić Banić
parent 5e62feed7f
commit 8644811efe
2 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -32,7 +31,7 @@ namespace CompatBot.Commands
if (ctx.Channel.IsPrivate)
header += $" | {"Invite link".PadRight(linkLength)}";
header += " | Server Name";
var result = new StringBuilder("```")
var result = new StringBuilder("Whitelisted discord servers:\n```")
.AppendLine(header)
.AppendLine("".PadRight(header.Length + 10, '-'));
var whitelistedInvites = await db.WhitelistedInvites.ToListAsync().ConfigureAwait(false);

View File

@ -18,9 +18,9 @@ namespace CompatBot.EventHandlers
internal static class DiscordInviteFilter
{
private const RegexOptions DefaultOptions = RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.Multiline;
private static readonly Regex InviteLink = new Regex(@"https?://discord(((app\.com/invite|\.gg)/(?<invite_id>.*?))|(\.me/(?<me_id>.*?)))(\s|\W|$)", DefaultOptions);
private static readonly Regex DiscordInviteLink = new Regex(@"https?://discord(app\.com/invite|\.gg)/(?<invite_id>.*?)(\s|\W|$)", DefaultOptions);
private static readonly Regex DiscordMeLink = new Regex(@"https?://discord\.me/(?<me_id>.*?)(\s|$)", DefaultOptions);
private static readonly Regex InviteLink = new Regex(@"(https?://)?discord(((app\.com/invite|\.gg)/(?<invite_id>.*?))|(\.me/(?<me_id>.*?)))(\s|\W|$)", DefaultOptions);
private static readonly Regex DiscordInviteLink = new Regex(@"(https?://)?discord(app\.com/invite|\.gg)/(?<invite_id>.*?)(\s|\W|$)", DefaultOptions);
private static readonly Regex DiscordMeLink = new Regex(@"(https?://)?discord\.me/(?<me_id>.*?)(\s|$)", DefaultOptions);
private static readonly HttpClient HttpClient = HttpClientFactory.Create(new CompressionMessageHandler());
public static Task OnMessageCreated(MessageCreateEventArgs args) => CheckMessageForInvitesAsync(args.Client, args.Message);