/// <summary> /// Wird aufgerufen, wenn der Benutzer normalen Text (kein Kommando) eingegeben hat /// </summary> /// <param name="authorid"></param> /// <param name="authorname"></param> /// <param name="chatid"></param> /// <param name="text"></param> /// <returns></returns> internal async Task processTextInput(long authorid, string authorname, long chatid, string text) { try { if (this.authors.isPostMode(authorid, authorname)) { // == NEW POST SUBMITTED == if (!SpamFilter.checkPostInput(text, out string posttext, out string message)) { // spamfilter hat zugeschlagen await this.telegramInputBot.SendTextMessageAsync( chatId : chatid, text : "Abgelehnt, Text ändern und erneut senden. Meldung des Spamfilters: " + message ); return; } this.statistics.increaseInteraction(); this.authors.resetCoolDown(authorid, authorname, Author.InteractionCooldownTimer.Posting); this.authors.resetCoolDown(authorid, authorname, Author.InteractionCooldownTimer.Default); this.authors.unsetModes(authorid, authorname); this.posts.addPosting(posttext, authorid); await this.telegramInputBot.SendTextMessageAsync( chatId : chatid, text : DRaumManager.ReplyPost + "\r\nMeldung des Spamfilters: " + message ); return; } if (this.authors.isFeedbackMode(authorid, authorname)) { // == Feedback == if (!SpamFilter.checkPostInput(text, out string feedbacktext, out string message)) { // spamfilter hat zugeschlagen await this.telegramInputBot.SendTextMessageAsync( chatId : chatid, text : "Abgelehnt, Text ändern und erneut senden. Meldung des Spamfilters: " + message ); return; } this.statistics.increaseInteraction(); this.authors.resetCoolDown(authorid, authorname, Author.InteractionCooldownTimer.Feedback); this.authors.resetCoolDown(authorid, authorname, Author.InteractionCooldownTimer.Default); this.authors.unsetModes(authorid, authorname); this.feedbackManager.enqueueFeedback( new FeedbackElement("Von: @" + authorname + " ID(" + authorid + ") : " + feedbacktext, chatid)); await this.telegramInputBot.SendTextMessageAsync( chatId : chatid, text : DRaumManager.ReplyFeedback ); } } catch (Exception ex) { logger.Error(ex, "Fehler beim Text-Verarbeiten"); } }
public void spamFilterTest() { string input = "& < > \" und <tag>"; Assert.IsFalse(SpamFilter.checkPostInput(input, out string output, out string message)); for (int i = 0; i < 100; i++) { input += "X"; } input = Utilities.telegramEntitiesToHtml(input, new MessageEntity[0]); Assert.IsTrue(SpamFilter.checkPostInput(input, out output, out message)); Assert.IsTrue(output.StartsWith("& < > " und <tag>")); }