/// <summary> /// Changes the content based on buffer /// </summary> /// <param name="data"></param> public void RewriteBuffer(string data) { lock (Mode) { buffer = data; Mode.Clear(); List <string> line = new List <string>(); line.AddRange(data.Split('\n')); rMode.Clear(); channelModes = ""; string positive = "+"; string negative = "-"; foreach (string xx in line) { bool rm = false; int CurrentParam = 1; List <string> parts = new List <string>(); parts.AddRange(xx.Split(' ')); if (parts.Count > 0) { if (parts[0].Contains("-") || parts[0].Contains("+")) { foreach (char CurrentMode in parts[0]) { switch (CurrentMode) { case '+': rm = false; continue; case '-': rm = true; continue; } // user mode, has a parameter if (core.irc.CUModes.Contains(CurrentMode) || core.irc.PModes.Contains(CurrentMode)) { if (parts.Count < CurrentParam + 1) { core.DebugLog("Mode: " + xx + " is invalid and can't be parsed"); return; } SimpleMode mode = new SimpleMode(CurrentMode, parts[CurrentParam]); if (rm) { rMode.Add(mode); } else { Mode.Add(mode); } CurrentParam++; continue; } // channel special mode with parameter if (core.irc.SModes.Contains(CurrentMode) || core.irc.XModes.Contains(CurrentMode)) { if (parts.Count < CurrentParam + 1) { core.DebugLog("Mode: " + xx + " is invalid and can't be parsed"); return; } SimpleMode mode = new SimpleMode(CurrentMode, parts[CurrentParam]); if (rm) { rMode.Add(mode); positive = positive.Replace(CurrentMode.ToString(), ""); negative += CurrentMode.ToString(); } else { Mode.Add(mode); negative = negative.Replace(CurrentMode.ToString(), ""); positive += CurrentMode.ToString(); } CurrentParam++; continue; } // channel mode if (core.irc.CModes.Contains(CurrentMode)) { SimpleMode mode = new SimpleMode(CurrentMode, null); if (rm) { rMode.Add(mode); positive = positive.Replace(CurrentMode.ToString(), ""); negative += CurrentMode.ToString(); } else { Mode.Add(mode); negative = negative.Replace(CurrentMode.ToString(), ""); positive += CurrentMode.ToString(); } continue; } } } } } if (positive.Length > 1) { channelModes += positive; } if (negative.Length > 1) { channelModes += negative; } } }
/// <summary> /// Changes the content based on buffer /// </summary> /// <param name="data"></param> public void RewriteBuffer(string data) { lock (Mode) { buffer = data; Mode.Clear(); List<string> line = new List<string>(); line.AddRange(data.Split('\n')); rMode.Clear(); channelModes = ""; string positive = "+"; string negative = "-"; foreach (string xx in line) { bool rm = false; int CurrentParam = 1; List<string> parts = new List<string>(); parts.AddRange(xx.Split(' ')); if (parts.Count > 0) { if (parts[0].Contains("-") || parts[0].Contains("+")) { foreach (char CurrentMode in parts[0]) { switch (CurrentMode) { case '+': rm = false; continue; case '-': rm = true; continue; } // user mode, has a parameter if (Core.irc.CUModes.Contains(CurrentMode) || Core.irc.PModes.Contains(CurrentMode)) { if (parts.Count < CurrentParam + 1) { Syslog.DebugLog("Mode: " + xx + " is invalid and can't be parsed"); return; } SimpleMode mode = new SimpleMode(CurrentMode, parts[CurrentParam]); if (rm) { rMode.Add(mode); } else { Mode.Add(mode); } CurrentParam++; continue; } // channel special mode with parameter if (Core.irc.SModes.Contains(CurrentMode) || Core.irc.XModes.Contains(CurrentMode)) { if (parts.Count < CurrentParam + 1) { Syslog.DebugLog("Mode: " + xx + " is invalid and can't be parsed"); return; } SimpleMode mode = new SimpleMode(CurrentMode, parts[CurrentParam]); if (rm) { rMode.Add(mode); positive = positive.Replace(CurrentMode.ToString(), ""); negative += CurrentMode.ToString(); } else { Mode.Add(mode); negative = negative.Replace(CurrentMode.ToString(), ""); positive += CurrentMode.ToString(); } CurrentParam++; continue; } // channel mode if (Core.irc.CModes.Contains(CurrentMode)) { SimpleMode mode = new SimpleMode(CurrentMode, null); if (rm) { rMode.Add(mode); positive = positive.Replace(CurrentMode.ToString(), ""); negative += CurrentMode.ToString(); } else { Mode.Add(mode); negative = negative.Replace(CurrentMode.ToString(), ""); positive += CurrentMode.ToString(); } continue; } } } } } if (positive.Length > 1) { channelModes += positive; } if (negative.Length > 1) { channelModes += negative; } } }