more tweaks

This commit is contained in:
13xforever 2019-07-26 23:31:49 +05:00
parent c3fc46b4ca
commit e5ae5902aa
5 changed files with 12 additions and 12 deletions

View File

@ -75,7 +75,7 @@ namespace CompatBot.Commands
if (isNewFilter)
{
filter.Context = FilterContext.Chat | FilterContext.Log;
filter.Actions = FilterAction.RemoveMessage | FilterAction.IssueWarning | FilterAction.SendMessage;
filter.Actions = FilterAction.RemoveContent | FilterAction.IssueWarning | FilterAction.SendMessage;
}
var (success, msg) = await EditFilterPropertiesAsync(ctx, db, filter).ConfigureAwait(false);
@ -351,7 +351,7 @@ namespace CompatBot.Commands
embed = FormatFilter(filter, errorMsg, 3)
.WithDescription(
"Actions that will be executed on positive match.\n" +
$"**`R`** = **`{FilterAction.RemoveMessage}`** will remove the message / log.\n" +
$"**`R`** = **`{FilterAction.RemoveContent}`** will remove the message / log.\n" +
$"**`W`** = **`{FilterAction.IssueWarning}`** will issue a warning to the user.\n" +
$"**`M`** = **`{FilterAction.SendMessage}`** send _a_ message with an explanation of why it was removed.\n" +
$"**`E`** = **`{FilterAction.ShowExplain}`** show `explain` for the specified term (**not implemented**).\n" +
@ -373,7 +373,7 @@ namespace CompatBot.Commands
if (emoji.Emoji == letterR)
{
filter.Actions ^= FilterAction.RemoveMessage;
filter.Actions ^= FilterAction.RemoveContent;
goto step3;
}
@ -409,7 +409,7 @@ namespace CompatBot.Commands
case "R":
case "REMOVE":
case "REMOVEMESSAGE":
newActions |= FilterAction.RemoveMessage;
newActions |= FilterAction.RemoveContent;
break;
case "W":
case "WARN":
@ -457,7 +457,7 @@ namespace CompatBot.Commands
msg = await msg.UpdateOrCreateMessageAsync(ctx.Channel, "Please specify filter **validation regex**", embed: embed).ConfigureAwait(false);
errorMsg = null;
var next = (filter.Actions & (FilterAction.SendMessage | FilterAction.ShowExplain)) == 0 ? firstPage : nextPage;
(msg, txt, emoji) = await interact.WaitForMessageOrReactionAsync(msg, ctx.User, InteractTimeout, abort, previousPage, next, trash, (filter.IsComplete() ? saveEdit : null)).ConfigureAwait(false);
(msg, txt, emoji) = await interact.WaitForMessageOrReactionAsync(msg, ctx.User, InteractTimeout, abort, previousPage, next, (string.IsNullOrEmpty(filter.ValidatingRegex) ? null : trash), (filter.IsComplete() ? saveEdit : null)).ConfigureAwait(false);
if (emoji != null)
{
if (emoji.Emoji == abort)

View File

@ -34,7 +34,7 @@ namespace CompatBot.Database
modelBuilder.Entity<Moderator>().HasIndex(m => m.DiscordId).IsUnique().HasName("moderator_discord_id");
modelBuilder.Entity<Piracystring>().HasIndex(ps => ps.String).IsUnique().HasName("piracystring_string");
modelBuilder.Entity<Piracystring>().Property(ps => ps.Context).HasDefaultValue(FilterContext.Chat | FilterContext.Log);
modelBuilder.Entity<Piracystring>().Property(ps => ps.Actions).HasDefaultValue(FilterAction.RemoveMessage | FilterAction.IssueWarning | FilterAction.SendMessage);
modelBuilder.Entity<Piracystring>().Property(ps => ps.Actions).HasDefaultValue(FilterAction.RemoveContent | FilterAction.IssueWarning | FilterAction.SendMessage);
modelBuilder.Entity<Warning>().HasIndex(w => w.DiscordId).HasName("warning_discord_id");
modelBuilder.Entity<Explanation>().HasIndex(e => e.Keyword).IsUnique().HasName("explanation_keyword");
modelBuilder.Entity<DisabledCommand>().HasIndex(c => c.Command).IsUnique().HasName("disabled_command_command");
@ -87,7 +87,7 @@ namespace CompatBot.Database
[Flags]
internal enum FilterAction
{
RemoveMessage = 0b_0000_0001,
RemoveContent = 0b_0000_0001,
IssueWarning = 0b_0000_0010,
ShowExplain = 0b_0000_0100,
SendMessage = 0b_0000_1000,

View File

@ -39,7 +39,7 @@ namespace CompatBot.Database.Providers
if (string.IsNullOrEmpty(h.Value.ValidatingRegex) || Regex.IsMatch(str, h.Value.ValidatingRegex, RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
result = h.Value;
return h.Value.Actions.HasFlag(FilterAction.RemoveMessage);
return h.Value.Actions.HasFlag(FilterAction.RemoveContent);
}
return true;
});
@ -82,12 +82,12 @@ namespace CompatBot.Database.Providers
if (trigger == null)
return true;
if (trigger.Actions.HasFlag(FilterAction.RemoveMessage))
if (trigger.Actions.HasFlag(FilterAction.RemoveContent))
{
try
{
await message.Channel.DeleteMessageAsync(message, $"Removed according to filter '{trigger}'").ConfigureAwait(false);
completedActions.Add(FilterAction.RemoveMessage);
completedActions.Add(FilterAction.RemoveContent);
}
catch
{

View File

@ -212,7 +212,7 @@ namespace CompatBot.EventHandlers.LogParsing
private static async Task PiracyCheckAsync(string line, LogParseState state)
{
if (await ContentFilter.FindTriggerAsync(FilterContext.Log, line).ConfigureAwait(false) is Piracystring match
&& match.Actions.HasFlag(FilterAction.RemoveMessage))
&& match.Actions.HasFlag(FilterAction.RemoveContent))
{
state.PiracyTrigger = match.String;
state.PiracyContext = line.ToUtf8();

View File

@ -10,7 +10,7 @@ namespace CompatBot.Utils.Extensions
{
private static readonly Dictionary<FilterAction, char> ActionFlags = new Dictionary<FilterAction, char>
{
[FilterAction.RemoveMessage] = 'r',
[FilterAction.RemoveContent] = 'r',
[FilterAction.IssueWarning] = 'w',
[FilterAction.SendMessage] = 'm',
[FilterAction.ShowExplain] = 'e',