/// <summary> /// tempore list user auto kick BANTIME /// </summary> public static void OnAutoKick(string user) { Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { if (SBanlist.UserInList(user)) { // kick // send kick commando to Irc MainWindow.Core.SendToIrc(@"/KICK " + user.Replace(":", string.Empty) + " autokick", true); } }); }
/// <summary> /// method send message to irc server /// </summary> /// <param name="s">string content message</param> /// <param name="iscommand"></param> public void SendToIrc(string s, bool iscommand = false) { if (UThread == null) { return; } //if (!UThread.IsAlive) { return;} string[] r = s.Split(new string[] { " ", "/" }, StringSplitOptions.None); _output = new StreamWriter(Ssock.GetStream()); try { // send command if (iscommand) { // auth privilege if (r[1] == "AUTH") { string[] content = s.Split(new string[] { " ", "/" }, StringSplitOptions.None); _output.Write(@"AUTH " + content[2] + @" " + content[3] + "\r\n"); _output.Flush(); // display message listviewchat system Sdelegates.OnChatCallback(@"system :", Application.Current.MainWindow.Resources.MergedDictionaries[0]["Authsucess"].ToString()); } // kick user else if (r[1] == "KICK") { // command kick ex : // KICK <#channel> <nick> <comment banned> string[] k = s.Split(new string[] { "/", " " }, StringSplitOptions.None); _output.Write(@"KICK " + MainWindow.Core.Conf.Chan + " " + k[2] + " " + k[3] + "\r\n"); _output.Flush(); } else if (r[1] == "BANTIME") { // created simple list auto kick user if join channel if banned for TIMEOUT SBanlist.AddBanList(r[2]); // add command to send in listviewchat Sdelegates.OnChatCallback(@"system: ", @"BANTIME => " + r[2]); // kick user // auto kick check list contains user Sdelegates.OnAutoKick(r[2]); } else if (r[1] == "UNBANTIME") { SBanlist.RemoveBanList(r[2]); // add command to send in listviewchat Sdelegates.OnChatCallback(@"system: ", @"UNBANTIME => " + r[2]); } else if (r[1] == "CLEARBANTIME") { SBanlist.ClearList(); // add command to send in listviewchat Sdelegates.OnChatCallback(@"system: ", @"CLEARBANTIME => CLEAN"); } else if (r[1] == "BANDAYS") { } // clear server channel chat else if (r[1] == "CLEAR") { Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { ((MainWindow)Application.Current.MainWindow).Listchat.Items.Clear(); Sdelegates.OnChatCallback(@"system: ", @"clean client chat"); }); } // send pure command to server else if (r[1] == "CMD") { // send pure command _output.Write(s.Replace("/CMD", string.Empty) + "\r\n"); _output.Flush(); } // Q PERMBAN <#channel> <banmask> [<reason>] else if (r[1] == "BANFOREVER") { } // show debug console else if (r[1] == "DEBUG") { if (Showconsole.ConsoleIsShow()) { Showconsole.ShowConsole(); } else { Showconsole.ShowConsole(false); } } // quit else if (r[1] == "QUIT") { _output.Write(@"QUIT" + "\r\n"); _output.Flush(); } // add command to send in listviewchat //Sdelegates.OnChatCallback(MainWindow.Core.Conf.Nick, // r[1].ToString()); Console.WriteLine(MainWindow.Core.Conf.Nick + @" " + r[1]); //return; } else { //// send pure command //_output.Write(s + "\r\n"); //_output.Flush(); //return; // // send simple message _output.Write("PRIVMSG " + MainWindow.Core.Conf.Chan + " : " + s + "\r\n"); _output.Flush(); // add message to send in listviewchat Sdelegates.OnChatCallback(MainWindow.Core.Conf.Owner, s); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Sdelegates.OnChatCallback(@"error: ", ex.HResult.ToString()); } }