<commit_before>﻿using System.Collections.Generic;
using System.Threading.Tasks;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.Utils;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using Microsoft.EntityFrameworkCore;

namespace CompatBot.Commands
{
    [Group("piracy"), RequiresBotModRole, RequiresDm]
    [Description("Used to manage piracy filters **in DM**")]
    internal sealed class Antipiracy: BaseCommandModuleCustom
    {
        [Command("list"), Aliases("show")]
        [Description("Lists all filters")]
        public async Task List(CommandContext ctx)
        {
            var table = new AsciiTable(
                new AsciiColumn("ID", alignToRight: true),
                new AsciiColumn("Trigger")
            );
            using (var db = new BotDb())
                foreach (var item in await db.Piracystring.ToListAsync().ConfigureAwait(false))
                    table.Add(item.Id.ToString(), item.String);
            await ctx.SendAutosplitMessageAsync(table.ToString()).ConfigureAwait(false);
        }

        [Command("add")]
        [Description("Adds a new piracy filter trigger")]
        public async Task Add(CommandContext ctx, [RemainingText, Description("A plain string to match")] string trigger)
        {
            var wasSuccessful = await PiracyStringProvider.AddAsync(trigger).ConfigureAwait(false);
            if (wasSuccessful)
                await ctx.ReactWithAsync(Config.Reactions.Success, "New trigger successfully saved!").ConfigureAwait(false);
            else
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Trigger already defined.").ConfigureAwait(false);
            if (wasSuccessful)
                await List(ctx).ConfigureAwait(false);
        }
<commit_msg>move antipiracy management up to sudoers for now<commit_after>﻿using System.Collections.Generic;
using System.Threading.Tasks;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.Utils;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using Microsoft.EntityFrameworkCore;

namespace CompatBot.Commands
{
    [Group("piracy"), RequiresBotSudoerRole, RequiresDm]
    [Description("Used to manage piracy filters **in DM**")]
    internal sealed class Antipiracy: BaseCommandModuleCustom
    {
        [Command("list"), Aliases("show")]
        [Description("Lists all filters")]
        public async Task List(CommandContext ctx)
        {
            var table = new AsciiTable(
                new AsciiColumn("ID", alignToRight: true),
                new AsciiColumn("Trigger")
            );
            using (var db = new BotDb())
                foreach (var item in await db.Piracystring.ToListAsync().ConfigureAwait(false))
                    table.Add(item.Id.ToString(), item.String);
            await ctx.SendAutosplitMessageAsync(table.ToString()).ConfigureAwait(false);
        }

        [Command("add")]
        [Description("Adds a new piracy filter trigger")]
        public async Task Add(CommandContext ctx, [RemainingText, Description("A plain string to match")] string trigger)
        {
            var wasSuccessful = await PiracyStringProvider.AddAsync(trigger).ConfigureAwait(false);
            if (wasSuccessful)
                await ctx.ReactWithAsync(Config.Reactions.Success, "New trigger successfully saved!").ConfigureAwait(false);
            else
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Trigger already defined.").ConfigureAwait(false);
            if (wasSuccessful)
                await List(ctx).ConfigureAwait(false);
        }

{'fraction_non_alphanumeric': 0.1002680965147453, 'fraction_numerical': 0.0, 'mean_word_length': 2.943974630021142, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2467935', 'n_tokens_mistral': 989, 'n_tokens_neox': 980, 'n_words': 231}