public string [] GetConfigBuddies(string strConfig) { ArrayList names = new ArrayList(); foreach (string strLine in strConfig.Split('\n')) { if (strLine.ToLower().Trim() == "done:") { break; } if (strLine.StartsWith("b")) { string strTemp = strLine.Replace("\r", null); int i = strTemp.IndexOf(":", 0); strTemp = strTemp.Remove(0, i + 1); i = strTemp.IndexOf(":", 0); strTemp = strTemp.Remove(i, strTemp.Length - (i - 1)); names.Add(TOCUser.Normalize(strTemp)); } } return((string [])names.ToArray(typeof(string))); }
public void SendMessage(string strUser, string strMsg, bool bAuto) { string strText; strText = string.Format("toc2_send_im {0} \"{1}\"{2}", TOCUser.Normalize(strUser), Encode(strMsg), bAuto ? " auto" : ""); Send(strText); }
private void Dispatch(string strIncoming) { if (OnServerMessage != null) { OnServerMessage(strIncoming); } Regex r = new Regex("(:)"); // Split on colon string[] strArray = r.Split(strIncoming); switch (strArray[0]) { case "CONFIG2": //if (AutoAddBuddies) // AddBuddies(GetConfigBuddies(strIncoming)); break; case "SIGN_ON": Send("toc_add_buddy " + user.GetName()); Send("toc_set_info \"" + m_strInfo + "\""); Send("toc_init_done"); if (OnSignedOn != null) { OnSignedOn(); } break; case "IM_IN2": if (OnIMIn != null) { string strMsg = string.Join("", strArray, 8, strArray.Length - 8); //string strMsg = strArray[8]; OnIMIn(TOCUser.Normalize(strArray[2]), Regex.Replace(strMsg, @"<(.|\n)*?>", string.Empty), strArray[4] == "T"); if (m_bGetLineWait) { m_GetLineString = Regex.Replace(strMsg, @"<(.|\n)*?>", string.Empty); m_bGetLineWait = false; m_Timer.Stop(); } } break; case "UPDATE_BUDDY2": if (OnUpdateBuddy != null) { OnUpdateBuddy(TOCUser.Normalize(strArray[2]), strArray[4] == "T"); } break; case "EVILED": if (OnEviled != null) { int iLvl = int.Parse(strArray[2]); if (strArray.Length == 5) { OnEviled(iLvl, false, TOCUser.Normalize(strArray[4])); } else if (strArray.Length == 4) { OnEviled(iLvl, true, ""); } } break; case "ERROR": if (OnError != null) { switch (strArray[2]) { case "980": OnError(@"Invalid login"); break; default: OnError(@"ERROR " + strArray[2] + ": There was an unknown error"); break; } //OnError( } break; case "CHAT_JOIN": if (OnChatJoined != null) { OnChatJoined(strArray[2], strArray[4]); } break; default: break; } }