Advertisement
ozakisama

AUTOMATA_ChatBox [DONE] BAUTISTANAS

Aug 13th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Text.RegularExpressions;
  10.  
  11. namespace AUTOMATA_ChatBox
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.         private string FilterWord(string text)
  20.         {
  21.             string pattern = @"([yY\s]+[aA@4\s]+[wW\s]+[aA@4]+)|" +
  22.                             @"([aA@4\s]+[wW\s]+[aA@4\s]+[yY]+)|" +
  23.                             @"([bB\s]+[oOuU0\s]+[aA@4\s]+[nN\s]+[gG6]+)|" +
  24.                             @"([nN\s]+[gG6\s]+[aA@4\s]+[oOuU0\s]+[bB]+)|" +
  25.                             @"([pP\s]+[iI1!\s]+[sS5$&zZ\s]+[tT+\s]+[iI1!]+)|" +
  26.                             @"([iI1!\s]+[tT+\s]+[sS5$&zZ\s]+[iI1!\s]+[pP]+)|" +
  27.                             @"([fF\s]+[uUvV\s]+[cC(<\s]+[kK]+)|" +
  28.                             @"([kK\s]+[cC(<\s]+[uUvV\s]+[fF]+)";
  29.  
  30.             string replace = string.Empty;
  31.             Regex reg = new Regex(pattern);
  32.             int i = 0;
  33.             while (i <= reg.Match(text, 0, text.Length).Length - 1)
  34.             {
  35.                 replace += "*";
  36.                 i++;
  37.             }
  38.             return reg.Replace(text, replace);
  39.         }
  40.  
  41.         private bool IsInvalidWord(string invalid)
  42.         {
  43.             return true;
  44.         }
  45.         private void btnSend_Click(object sender, EventArgs e)
  46.         {
  47.             int flag = IsInvalidWord(FilterWord(txttext.Text)) ? 1 : 0;
  48.             switch (flag)
  49.             {
  50.                 case 0:
  51.                     if (IsInvalidWord(FilterWord(txttext.Text)))
  52.                     {
  53.                         goto default;
  54.                     }
  55.                     else
  56.                     {
  57.                         rtbdispaly.Text += "\r\n>>" + txttext.Text;
  58.                     }
  59.                     break;
  60.                 default:
  61.                     rtbdispaly.Text += "\r\n>>" + FilterWord(txttext.Text);
  62.                     break;
  63.             }
  64.             rtbdispaly.SelectionStart = rtbdispaly.Text.Length;
  65.             rtbdispaly.ScrollToCaret();
  66.             txttext.Clear();
  67.             txttext.Focus();
  68.         }
  69.  
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement