Exemplo n.º 1
0
        public async Task <IActionResult> AddQuestion(NewQuestionModel model)
        {
            var userId   = _userManager.GetUserId(User);
            var user     = _userManager.FindByIdAsync(userId).Result;
            var question = BuildPost(model, user);

            string[] censoredWords = System.IO.File.ReadAllLines(@"CensoredWords.txt");
            Censor   censor        = new Censor(censoredWords);

            question.QuestionTitle   = censor.CensorText(question.QuestionTitle);
            question.QuestionContent = censor.CensorText(question.QuestionContent);

            await _questionImplementation.AddQuestion(question);

            await _applicationUserImplementation.UpdateUserRating(userId, typeof(Question));

            return(RedirectToAction("Index", "Question", new { id = question.QuestionId }));
        }
Exemplo n.º 2
0
        public void NoDirtyWords()
        {
            var censor = new Censor(new []{"helloworld"});
            var test = "The dirty word is not here";
            var correct = "The dirty word is not here";

            var result = censor.CensorText(test);

            Assert.IsFalse(censor.HasCensoredWord(test), "The text is not dirty, but returned true");
            Assert.AreEqual(result, correct, "All words were not censored correctly");
        }
Exemplo n.º 3
0
        [Test]//Original from post
        public void WildcardDirty()
        {
            var censor = new Censor(new []
            {
                "gosh",
                "drat",
                "darn*",
            });

            string result;

            result = censor.CensorText("I stubbed my toe. Gosh it hurts!");
            Assert.AreEqual(result, "I stubbed my toe. **** it hurts!");

            result = censor.CensorText("The midrate on the USD -> EUR forex trade has soured my day. Drat!");
            Assert.AreEqual(result, "The midrate on the USD -> EUR forex trade has soured my day. ****!");

            result = censor.CensorText("Gosh darnit, my shoe laces are undone.");
            Assert.AreEqual(result, "**** ******, my shoe laces are undone.");
        }
Exemplo n.º 4
0
        public void DirtyWordsWithSpaces()
        {
            var test    = "The dirty word hello world and Hello World";
            var censor  = new Censor(new [] { "hello world" });
            var correct = "The dirty word *********** and ***********";

            var result = censor.CensorText(test);

            Assert.IsTrue(censor.HasCensoredWord(test), "The text is dirty, but returned false");
            Assert.AreEqual(result, correct, "All words were not filtered");
        }
Exemplo n.º 5
0
        public void NoDirtyWords()
        {
            var censor  = new Censor(new [] { "helloworld" });
            var test    = "The dirty word is not here";
            var correct = "The dirty word is not here";

            var result = censor.CensorText(test);

            Assert.IsFalse(censor.HasCensoredWord(test), "The text is not dirty, but returned true");
            Assert.AreEqual(result, correct, "All words were not censored correctly");
        }
Exemplo n.º 6
0
        public void DirtyWordsWithSpaces()
        {
            var test = "The dirty word hello world and Hello World";
            var censor = new Censor(new []{"hello world"});
            var correct = "The dirty word *********** and ***********";

            var result = censor.CensorText(test);

            Assert.IsTrue(censor.HasCensoredWord(test), "The text is dirty, but returned false");
            Assert.AreEqual(result, correct, "All words were not filtered");

        }
Exemplo n.º 7
0
        public string AutomaticReviewEditor(string originalDescription)
        {
            var censoredWords = this.context.CensoredWords
                                .Select(x => x.Word)
                                .ToList();

            var censor = new Censor(censoredWords);

            var editDescription = censor.CensorText(originalDescription);

            return(editDescription);
        }
    void Update()
    {
        if (Input.GetKey(KeyCode.Return))          //The if part is optional.
        {
            textToFilter.text = censor.CensorText(textToFilter.text);
        }

        //You can use this anywhere:
        // player.NickName = censor.CensorText(username.text);

        //The pattern is:
        // filtered = censor.CensorText(InputTextGoesHere);
    }
Exemplo n.º 9
0
        public async Task GoogleAsyc([Remainder] string searchQuery)
        {
            //checks if the search fails the censor
            if (censor.CensorText(searchQuery))
            {
                //if so it sends an embed explaining the why the request failed
                EmbedBuilder builder = new EmbedBuilder()
                {
                    Author       = new EmbedAuthorBuilder().WithName("Error"),
                    Title        = "Your request could not be completed",
                    Description  = Context.Message.Author.Mention + " Your request most likely contained profanity and therefore was not completed.  Please refined your request so that it does not contain profanity.  Your original request has been removed.",
                    ThumbnailUrl = "https://cdn0.iconfinder.com/data/icons/small-n-flat/24/678069-sign-error-512.png",
                    Color        = Color.DarkRed
                };


                await ReplyAsync(embed : builder.Build());

                //deletes orignal request
                await Context.Message.DeleteAsync();
            }
            //if it passes the censor complete the search
            else
            {
                GoogleResults searchResults = await searchService.SearchAsync(searchQuery);

                //the following code is responsible for bulding the embed and sending it
                EmbedAuthorBuilder EAB = new EmbedAuthorBuilder()
                {
                    Name = "Main Result:"
                };

                EmbedBuilder embedBuilder = new EmbedBuilder()
                {
                    Author       = EAB,
                    Title        = searchResults.Items[0].Title,
                    Url          = searchResults.Items[0].Link,
                    ThumbnailUrl = searchResults.Items[0].PageMap.CseThumbnail[0].Src,
                    Color        = new Color?(new Color(66, 133, 244)),
                    Footer       = new EmbedFooterBuilder().WithText("Search Requested").WithIconUrl("https://cdn4.iconfinder.com/data/icons/new-google-logo-2015/400/new-google-favicon-512.png")
                }
                .AddField("Result 2", "[" + searchResults.Items[1].Title + "](" + searchResults.Items[1].Link + ")", false)
                .AddField("Result 3", "[" + searchResults.Items[2].Title + "](" + searchResults.Items[2].Link + ")", false)
                .WithCurrentTimestamp();
                await ReplyAsync(embed: embedBuilder.Build());
            }
        }
Exemplo n.º 10
0
        public async Task <IActionResult> AddAnswer(QuestionIndexModel model)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var answer = BuildReply(model, user);

            string[] censoredWords = System.IO.File.ReadAllLines(@"CensoredWords.txt");
            Censor   censor        = new Censor(censoredWords);

            answer.AnswerContent = censor.CensorText(answer.AnswerContent);

            await _questionImplementation.AddAnswer(answer);

            await _applicationUserImplementation.UpdateUserRating(userId, typeof(Answer));

            return(RedirectToAction("Index", "Question", new { id = model.QuestionId }));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> AddStatus(AddStatusModel model, StatusCategoryListingModel dol)
        {
            var userId = _userManager.GetUserId(User);
            var user   = _userManager.FindByIdAsync(userId).Result;
            var status = BuildPost(model, user, dol);

            string[] censoredWords = System.IO.File.ReadAllLines(@"CensoredWords.txt");
            Censor   censor        = new Censor(censoredWords);

            status.StatusTitle = censor.CensorText(status.StatusTitle);



            await _statusImplementation.AddStatus(status);

            await _applicationUserImplementation.UpdateUserRating(userId, typeof(Status));

            return(RedirectToAction("Index", "Status", new { id = status.StatusId }));
        }
Exemplo n.º 12
0
        public string CrapCensor(string censorSomeWords)
        {
            var censoredWords = new List <string>
            {
                "gosh",
                "drat",
                "darn*",
                "f**k",
                "anal",
                "anus",
                "arse",
                "ass",
                "ballsack",
                "balls",
                "bastard",
                "bitch",
                "biatch",
                "bloody",
                "b*****b",
                "blow job",
                "bollock",
                "bollok",
                "boner",
                "boob",
                "bugger",
                "bum",
                "butt",
                "b******g",
                "clitoris",
                "c**k",
                "coon",
                "crap",
                "c**t",
                "damn",
                "dick",
                "d***o",
                "dyke",
                "f*g",
                "feck",
                "f*****e",
                "f******o",
                "f******g",
                "f**k",
                "f u c k",
                "f*********r",
                "fudge packer",
                "flange",
                "Goddamn",
                "God damn",
                "hell",
                "h**o",
                "jerk",
                "j**z",
                "k*****d",
                "knob end",
                "labia",
                "lmfao",
                "muff",
                "nigger",
                "n***a",
                "omg",
                "penis",
                "piss",
                "poop",
                "prick",
                "pube",
                "pussy",
                "queer",
                "scrotum",
                "sex",
                "shit",
                "s hit",
                "sh1t",
                "s**t",
                "s****a",
                "spunk",
                "tit",
                "t**s",
                "tosser",
                "turd",
                "twat",
                "v****a",
                "wank",
                "w***e",
                "wtf",
                "ji bai",
                "jibai",
                "na bei",
                "cb",
                "ccb",
                "kns",
                "mf",
                "m**********r",
                "stupid",
                "f****t"
            };
            var    censor = new Censor(censoredWords);
            string result;

            result = censor.CensorText(censorSomeWords);
            return(result);
        }
Exemplo n.º 13
0
        [Test]//Original from post
        public void WildcardDirty()
        {
            var censor = new Censor(new []
                {
                    "gosh",
                    "drat",
                    "darn*",
                });

            string result;

            result = censor.CensorText("I stubbed my toe. Gosh it hurts!");
            Assert.AreEqual(result, "I stubbed my toe. **** it hurts!");

            result = censor.CensorText("The midrate on the USD -> EUR forex trade has soured my day. Drat!");
            Assert.AreEqual(result, "The midrate on the USD -> EUR forex trade has soured my day. ****!");

            result = censor.CensorText("Gosh darnit, my shoe laces are undone.");
            Assert.AreEqual(result, "**** ******, my shoe laces are undone.");
        }
Exemplo n.º 14
0
        public static int Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var path          = args[0];
            var censoredWords = args[1];


            if (string.IsNullOrWhiteSpace(path))
            {
                Console.WriteLine($"Wrong path was send as argument.");
                return(-1);
            }

            if (string.IsNullOrWhiteSpace(censoredWords))
            {
                Console.WriteLine("No censored words were given");
                return(-1);
            }

            var directoryInfo = new DirectoryInfo(path);

            if (!directoryInfo.Exists)
            {
                return(-1);
            }

            var censorResults = new List <CensoredResult>();

            var censor = new Censor(censoredWords.Split(","));

            foreach (var file in directoryInfo.EnumerateFiles("*.md", SearchOption.AllDirectories))
            {
                try
                {
                    using (var stream = file.OpenText())
                    {
                        int    lineNumber = 0;
                        string line;
                        while ((line = stream.ReadLine()) != null)
                        {
                            lineNumber++;
                            if (censor.HasCensoredWord(line))
                            {
                                var censoredResult = new CensoredResult();
                                censoredResult.FileName     = file.FullName;
                                censoredResult.LineNumber   = lineNumber;
                                censoredResult.CensoredLine = censor.CensorText(line);
                                censorResults.Add(censoredResult);
                            }
                        }
                    }
                }
                catch
                {
                    continue;
                }
            }

            if (censorResults.Count > 0)
            {
                Console.WriteLine($"{censorResults.Count} Censors found");
                var jsonString = JsonConvert.SerializeObject(censorResults, Formatting.Indented);
                Console.WriteLine(jsonString);
                return(-1);
            }

            return(0);
        }