Иконка ресурса

FREE BetterChatAutomatedFilter : 1.0.8 1.0.8

Нет прав для скачивания
C#:
using Facepunch;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Con = ConVar;
namespace Oxide.Plugins {
    [Info("BetterChatAutomatedFilter", "Reheight", "1.0.8")]
    class BetterChatAutomatedFilter : CovalencePlugin {
        [PluginReference]
        private Plugin BetterChat, BetterChatMute, DiscordMessages;
#region Configuration
        Configuration config;
        class Configuration {
            [JsonProperty(PropertyName = "Settings")]
            public Settings settings = new Settings();
            public class Settings {
                [JsonProperty(PropertyName = "Blacklisted Term Checking")]
                public bool BlacklistedTermChecking = true;
                [JsonProperty(PropertyName = "Blacklisted", ObjectCreationHandling = ObjectCreationHandling.Replace)]
                public string[] Blacklisted = new string[] {
                    "nigger", "faggot", "n1gg3r", "n1gger", "nigg3r", "n!gg3r", "n!gger", "f4ggot", "f4gg0t", "fagg0t", "fag", "f4g", "f@g", "f4got", "f4g0t", "fag0t", "f4got", "f4g0t", "fag0t", "fagg", "f4gg", "f@gg", "nig", "n1g", "nigga", "niggah", "nigguh", "n1gg4", "n1gga", "nigg4", "nigg", "n1gg", "niga", "nigah", "niguh", "n1g4", "n1ga", "nig4", "n!g", "n!gga", "n!ggah", "n!gguh", "n!gg4", "n!gg", "n!ga", "n!gah", "n!guh", "n!g4", "n!ga", "n!g4", "queer", "que3r", "qu3er", "qu33r", "niggers", "nlggers", "n!ggers", "faggots", "n1gg3rs", "n1ggers", "nigg3rs", "n!gg3rs", "n!ggers", "n!gg3rs", "f4ggots", "f4gg0ts", "fagg0ts", "fags", "f4gs", "f@gs", "nigs", "n1gs", "niggas", "niggahs", "nigguhs", "nlggas", "nlggahs", "nlgguhs", "n1gg4s", "n1ggas", "nigg4s", "queers", "que3rs", "qu3ers", "qu33rs", "nigger$", "faggot$", "n1gg3r$", "n1gger$", "nigg3r$", "f4ggot$", "f4gg0t$", "fagg0t$", "fag$", "f4g$", "f@g$", "nig$", "n1g$", "nigga$", "niggah$", "nigguh$", "n1gg4$", "n1gga$", "nigg4$", "queer$", "que3r$", "qu3er$", "qu33r$", "nigger5", "faggot5", "n1gg3r5", "n1gger5", "nigg3r5", "f4ggot5", "f4gg0t5", "fagg0t5", "fag5", "f4g5", "f@g5", "niger5", "fagot5", "n1g3r5", "n1ger5", "nig3r5", "f4got5", "f4g0t5", "fag0t5", "fagg5", "f4gg5", "f@gg5", "nig5", "n1g5", "nigg5", "n1gg5", "nigga5", "niggah5", "nigguh5", "n1gg45", "n1gga5", "nigg45", "queer5", "que3r5", "qu3er5", "qu33r5", "niqqer", "faqqot", "n1qq3r", "n1qqer", "niqq3r", "n!qq3r", "n!qqer", "f4qqot", "f4qq0t", "faqq0t", "faq", "f4q", "f@q", "f4qot", "f4q0t", "faq0t", "f4qot", "f4q0t", "faq0t", "faqq", "f4qq", "f@qq", "niq", "n1q", "niqqa", "niqqah", "niqquh", "n1qq4", "n1qqa", "niqq4", "niqq", "n1qq", "niqa", "niqah", "niquh", "n1q4", "n1qa", "niq4", "n!q", "n!qqa", "n!qqah", "n!qquh", "n!qq4", "n!qq", "n!qa", "n!qah", "n!quh", "n!q4", "n!qa", "n!q4", "niqqers", "nlqqers", "n!qqers", "faqqots", "n1qq3rs", "n1qqers", "niqq3rs", "n!qq3rs", "n!qqers", "n!qq3rs", "f4qqots", "f4qq0ts", "faqq0ts", "faqs", "f4qs", "f@qs", "niqs", "n1qs", "niqqas", "niqqahs", "niqquhs", "nlqqas", "nlqqahs", "nlqquhs", "n1qq4s", "n1qqas", "niqq4s", "niqqer$", "faqqot$", "n1qq3r$", "n1qqer$", "niqq3r$", "f4qqot$", "f4qq0t$", "faqq0t$", "faq$", "f4q$", "f@q$", "niq$", "n1q$", "niqqa$", "niqqah$", "niqquh$", "n1qq4$", "n1qqa$", "niqq4$", "niqqer5", "faqqot5", "n1qq3r5", "n1qqer5", "niqq3r5", "f4qqot5", "f4qq0t5", "faqq0t5", "faq5", "f4q5", "f@q5", "niqer5", "faqot5", "n1q3r5", "n1qer5", "niq3r5", "f4qot5", "f4q0t5", "faq0t5", "faqq5", "f4qq5", "f@qq5", "niq5", "n1q5", "niqq5", "n1qq5", "niqqa5", "niqqah5", "niqquh5", "n1qq45", "n1qqa5", "niqq45"
                }
                ;
                [JsonProperty(PropertyName = "Mute Enabled")]
                public bool MuteEnabled = true;
                [JsonProperty(PropertyName = "MuteHours")]
                public int MuteHours = 1;
                [JsonProperty(PropertyName = "Enable Regex Checking")]
                public bool RegexChecking = true;
                [JsonProperty(PropertyName = "Blacklisted REGEXs")]
                public string[] BlacklistedREGEX = new string[] {
                    "([ΝNn]+[Ii1l]+[Gg9]+[Gg9]+[Ee3]+[Rr]+)|([ΝNn]+[Ee3]+[Gg9]+[Ee3]+[Rr]+(?!en))|([ΝNn]+[Ee3]+[Gg9]+[Rr]+[Oo]+)|([ΝNn]+[Ii1l]+[Gg9]+[Ee3]+[Rr]+(?!ia))|([ΝNn]+[Ii1l]+[Gg9]+[Gg9]+[Uu]+[Rr]+)|([ΝNn]+[Ii1l]+[Gg9]+[Gg9]+[Aa4])"
                }
                ;
                [JsonProperty(PropertyName = "WebhookEnabled")]
                public bool WebhookEnabled = false;
                [JsonProperty(PropertyName = "WebhookURL")]
                public string WebhookURL = "DISCORD WEB HOOK";
                [JsonProperty(PropertyName = "Ignore Team Chat")]
                public bool IgnoreTeam = false;
                [JsonProperty(PropertyName = "Admin Bypass Permission")]
                public string AdminBypassPermission = "betterchatautomatedfilter.bypass";
                [JsonProperty(PropertyName = "Multiply By Mutable Words Count")]
                public bool MuteMultiplyCount = false;
                [JsonProperty(PropertyName = "Mute Reason")]
                public string MuteReason = "Prohibited Word Usage Attempt - Automated";
            }
        }
        private void Init() {
            permission.RegisterPermission(config.settings.AdminBypassPermission, this);
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                config = Config.ReadObject<Configuration>();
                if (config == null) throw new Exception();
            }
            catch {
                Config.WriteObject(config, false, $"{Interface.Oxide.ConfigDirectory}/{Name}.jsonError");
                PrintError("The configuration for BetterChatAutomatedFilter seems to contain and error and was replaced with the default configuration, your previous configuration has been renamed with a .jsonError extension!");
                LoadDefaultConfig();
            }
        }
        protected override void LoadDefaultConfig() => config = new Configuration();
        protected override void SaveConfig() => Config.WriteObject(config);
#endregion
        private void OnBetterChat(Dictionary<string, object> data) {
            Con.Chat.ChatChannel channel = (Con.Chat.ChatChannel)data["ChatChannel"];
            if (config.settings.IgnoreTeam && channel.ToString() == "Team") return;
            var player = data["Player"] as IPlayer;
            var message = data["Message"] as string;
            if (BetterChatMute.Call<bool>("API_IsMuted", player)) return;
            string[] messageArray = message.ToLower().Split(' ');
            List<string> mutableWords = Pool.GetList<String>();
            if (config.settings.BlacklistedTermChecking) {
                foreach (string word in config.settings.Blacklisted) {
                    if (messageArray.Contains<string>(word.ToLower())) {
                        mutableWords.Add(word.ToLower());
                    }
                }
            }
            if (config.settings.RegexChecking) {
                foreach (string entry in config.settings.BlacklistedREGEX) {
                    Regex rx = new Regex($@"{entry}");
                    foreach (string word in messageArray) {
                        if (rx.IsMatch(word.ToLower()) && !mutableWords.Contains(word.ToLower())) mutableWords.Add(word.ToLower());
                    }
                }
            }
            if (mutableWords.Count > 0) {
                if (player.HasPermission(config.settings.AdminBypassPermission)) return;
                data["CancelOption"] = 2;
                Puts($"{player.Name} ({player.Id}) was flagged for attempting to say: {message}");
                if (config.settings.MuteEnabled) {
                    if (!BetterChatMute) {
                        Puts("You do not have BetterChatMute installed, this plugin requires BetterChatMute to work. You can install this plugin at the following link!\nhttps://umod.org/plugins/better-chat-mute");
                    }
                    else {
                        int muteHours = config.settings.MuteMultiplyCount ? config.settings.MuteHours * mutableWords.Count : config.settings.MuteHours;
                        server.Command("mute", player.Id, $"{muteHours}h", config.settings.MuteReason);
                    }
                }
                if (config.settings.WebhookEnabled) {
                    object fields = new[] {
                        new {
                            name = "Player:", value = $"[{player.Name}](https://www.steamcommunity.com/profiles/{player.Id}) ({player.Id})", inline = false
                        }
                        , new {
                            name = "Server", value = $"```{server.Name}```", inline = false
                        }
                        , new {
                            name = "Message:", value = $"```{message}```", inline = false
                        }
                        , new {
                            name = "Detected Terms:", value = $"```- {String.Join("\n- ", mutableWords)}```", inline = false
                        }
                    }
                    ;
                    string json = JsonConvert.SerializeObject(fields);
                    if (!DiscordMessages) {
                        Puts("We are unable to send a Discord Webhook as you don't have DiscordMessages plugin installed. You can find this plugin at the following link!\nhttps://umod.org/plugins/discord-messages");
                    }
                    else {
                        DiscordMessages?.Call("API_SendFancyMessage", config.settings.WebhookURL, "Automated Mute", 4048011, json);
                    }
                }
            }
            Pool.FreeList(ref mutableWords);
            return;
        }
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху