Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (sender.Equals(button1))
            {
                if (listBox1.SelectedIndex <= 0)
                {
                    return;
                }
            }
            else
            {
                if (listBox1.SelectedIndex == listBox1.Items.Count - 1)
                {
                    return;
                }
            }

            ReplaceFilter a1 = (ReplaceFilter)listBox1.SelectedItem;

            listBox1.SelectedIndex += sender.Equals(button1) ? -1 : 1;
            ReplaceFilter a2 = (ReplaceFilter)listBox1.SelectedItem;

            ReplaceFilter.Swap(a1, a2);

            Reupdate = true;
            UpdList();
        }
Exemple #2
0
        public static void Swap(ReplaceFilter pi, ReplaceFilter pj)
        {
            dynamic tmp = pi.Content;

            pi.Content = pj.Content;
            pj.Content = tmp;

            tmp    = pi.Key;
            pi.Key = pj.Key;
            pj.Key = tmp;
        }
Exemple #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            ReplaceFilter tmp = new ReplaceFilter("");

            FilterEdit o = new FilterEdit(tmp);

            o.ShowDialog();

            ReplaseFilter.Collection.Add(tmp);

            Reupdate = true;

            UpdList();
        }
Exemple #4
0
        public FilterEdit(ReplaceFilter unit)
        {
            InitializeComponent();

            filter = unit;

            textBox1.Text = unit.Key;

            foreach (Rule rule in Rules.RuleCollection)
            {
                comboBox1.Items.Add(rule.RuleID);
            }
            comboBox1.SelectedIndex = comboBox1.Items.Count - 1;
        }
Exemple #5
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }

            ReplaceFilter tmp =
                ReplaseFilter.Collection.Where(x => x.Z).FirstOrDefault(x => x.Key == (string)listBox1.SelectedItem);

            if (tmp == null)
            {
                tmp = new ReplaceFilter((string)listBox1.SelectedItem, true);
                ReplaseFilter.Collection.Add(tmp);
            }

            FilterEdit o = new FilterEdit(tmp);

            o.ShowDialog();
        }
Exemple #6
0
        private static void Init()
        {
            Collection = new List <ReplaceFilter>();

            ReplaceFilter say = new ReplaceFilter("%say");

            say.Content.Add(new FilterUnit("Default", " say, "));
            say.Content.Add(new FilterUnit("Russian", " говорит, "));

            //ReplaceFilter me = new ReplaceFilter("%me");
            //me.Content.Add("Default", " dreaming, ");
            //me.Content.Add("Russian", " думает, ");

            ReplaceFilter rename = new ReplaceFilter("%rename");

            rename.Content.Add(new FilterUnit("Default", "%1 now sound as %2"));
            rename.Content.Add(new FilterUnit("Russian", "%1 теперь звучит как %2"));

            Collection.Add(say);
            //Collection.Add(me.Key, me);
            Collection.Add(rename);
        }
Exemple #7
0
        private void ListennerOnMessage(BCMessage msg)
        {
            UsersController.Control.Add(msg.Name);

            if (msg.Name.ToLower() == msg.Service.ToLower())
            {
                LogController.Add($"[{msg.Service}] [SysMsg] {msg.Name} : {msg.Text}");
                return;
            }

            if (UsersController.Control.IsInored(msg.Name))
            {
                LogController.Add($"[{msg.Service}] [IGONORED] {msg.Name} : {msg.Text}");
                return;
            }

            Rule r = Rules.RuleCollection.FirstOrDefault(x => x.CanReadThis(msg.Text.ToLower()));

            if (r.VoiceID == "null")
            {
                LogController.Add($"[{msg.Service}] [NULL VOICE] {msg.Name} : {msg.Text}");
                return;
            }

            if (msg.Text[0] == '+')
            {
                string[] strs = msg.Text.Split(new[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);

                if (strs.Length == 1)
                {
                    return;
                }

                switch (strs[0])
                {
                case "+s":
                {
                    ReplaceFilter rpls = ReplaseFilter.Collection.Where(x => x.Z).FirstOrDefault(x => x.Key == msg.Name);

                    if (rpls == null)
                    {
                        rpls = new ReplaceFilter(msg.Name, true);
                        ReplaseFilter.Collection.Add(rpls);
                    }
                    if (rpls.Contains(r.RuleID))
                    {
                        rpls.Remove(r.RuleID);
                    }

                    string        txt     = strs[1];
                    List <string> tsmiles = ATextClear(ref txt);

                    LogController.Add($"[{msg.Service}] {msg.Name} -> {txt}");

                    ReplaseFilter.FilterThisShit(ref txt, r.RuleID);
                    BTextClear(tsmiles, ref txt);

                    if (!TextCheck(txt, 15, 15))
                    {
                        LogController.Add($"[{msg.Service}] [FILTERED] {msg.Name} : {txt}");
                        return;
                    }

                    rpls.Content.Add(new FilterUnit(r.RuleID, txt));

                    Form1.Speak(r.VoiceID, ConstantsWords.Get("%rename", r.RuleID).Replace("%1", msg.Name).Replace("%2", txt));



                    return;
                }
                    //case "+n":
                    //{
                    //        Form1.voice.Speak("", SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
                    //        return;
                    //}
                }
            }


            string text = msg.Text;

            List <string> smiles = ATextClear(ref text);

            LogController.Add($"[{msg.Service}] {msg.Name} : {text}");

            ReplaseFilter.FilterThisShit(ref text, r.RuleID);
            BTextClear(smiles, ref text);

            if (!TextCheck(text, 200, 15))
            {
                LogController.Add($"[{msg.Service}] [FILTERED] {msg.Name} : {text}");
                return;
            }

            string name = msg.Name;

            ReplaseFilter.FilterThisShit(ref name, r.RuleID, true);

            Form1.Speak(r.VoiceID, $"{name} {ConstantsWords.Get("%say",r.RuleID)} {text}");
        }