mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-02-02 16:31:52 +00:00
use role whitelist for piracy checks
This commit is contained in:
parent
2bf9221a53
commit
89f58e2201
@ -30,6 +30,9 @@ namespace CompatBot.EventHandlers
|
||||
if (string.IsNullOrEmpty(message.Content) || message.Content.StartsWith(Config.CommandPrefix))
|
||||
return true;
|
||||
|
||||
if ((message.Author as DiscordMember)?.Roles.IsWhitelisted() ?? false)
|
||||
return true;
|
||||
|
||||
string trigger = null;
|
||||
bool needsAttention = false;
|
||||
try
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using CompatBot.Utils;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.EventArgs;
|
||||
|
||||
@ -9,7 +9,7 @@ namespace CompatBot.EventHandlers
|
||||
{
|
||||
internal class LogsAsTextMonitor
|
||||
{
|
||||
private static readonly Regex LogLine = new Regex(@"^·|^\w {(rsx|PPU|SPU)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
|
||||
private static readonly Regex LogLine = new Regex(@"^·|^(\w|!) ({(rsx|PPU|SPU)|LDR:)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
|
||||
|
||||
public static async Task OnMessageCreated(MessageCreateEventArgs args)
|
||||
{
|
||||
@ -22,11 +22,17 @@ namespace CompatBot.EventHandlers
|
||||
if (!"help".Equals(args.Channel.Name, StringComparison.InvariantCultureIgnoreCase))
|
||||
return;
|
||||
|
||||
if ((args.Message.Author as DiscordMember)?.Roles?.Any() ?? false)
|
||||
if ((args.Message.Author as DiscordMember)?.Roles.IsWhitelisted() ?? false)
|
||||
return;
|
||||
|
||||
if (LogLine.IsMatch(args.Message.Content))
|
||||
await args.Channel.SendMessageAsync($"{args.Message.Author.Mention} please upload the full log file instead of pasting some random bits that might be completely irrelevant").ConfigureAwait(false);
|
||||
{
|
||||
if (args.Message.Content.Contains("LDR:") && args.Message.Content.Contains("fs::file is null"))
|
||||
await args.Channel.SendMessageAsync($"{args.Message.Author.Mention} this error usually indicates a missing `.rap` license file.{Environment.NewLine}" +
|
||||
"Please follow the quickstart guide to get a proper dump of a digital title.").ConfigureAwait(false);
|
||||
else
|
||||
await args.Channel.SendMessageAsync($"{args.Message.Author.Mention} please upload the full log file instead of pasting some random bits that might be completely irrelevant").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace CompatBot.EventHandlers
|
||||
|
||||
// in case it's not in cache and doesn't contain any info, including Author
|
||||
message = await channel.GetMessageAsync(message.Id).ConfigureAwait(false);
|
||||
if ((message.Author as DiscordMember)?.Roles.Any(r => Config.Moderation.RoleWhiteList.Contains(r.Name)) ?? false)
|
||||
if ((message.Author as DiscordMember)?.Roles.IsWhitelisted() ?? false)
|
||||
return;
|
||||
|
||||
var users = await message.GetReactionsAsync(emoji).ConfigureAwait(false);
|
||||
|
15
CompatBot/Utils/RolesExtensions.cs
Normal file
15
CompatBot/Utils/RolesExtensions.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DSharpPlus.Entities;
|
||||
|
||||
namespace CompatBot.Utils
|
||||
{
|
||||
internal static class RolesExtensions
|
||||
{
|
||||
public static bool IsWhitelisted(this IEnumerable<DiscordRole> memberRoles)
|
||||
{
|
||||
return memberRoles?.Any(r => Config.Moderation.RoleWhiteList.Contains(r.Name)) ?? false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user