private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Rules.Save(); ReplaseFilter.Save(); ConstantsWords.Save(); UsersController.Control.Save(); }
public Form1() { InitializeComponent(); Rules.Load(); ReplaseFilter.Load(); ConstantsWords.Load(); UsersController.Control.Load(); CheckForIllegalCrossThreadCalls = false; foreach (SpObjectToken token in voice.GetVoices("", "")) { comboBox1.Items.Add(token.GetDescription(0)); } comboBox1.SelectedIndex = 0; ChatListenner c = new ChatListenner(); UsersController.Control.OnChange += () => { listBox1.Items.Clear(); listBox1.BeginUpdate(); foreach (string s in UsersController.Control.Users) { listBox1.Items.Add((UsersController.Control.IsInored(s) ? "[i] " : "") + s); } listBox1.EndUpdate(); }; }
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}"); }