Пример #1
0
        public void SendMessage(string strUser, string strMsg, bool bAuto)
        {
            string strText;

            strText = string.Format("toc_send_im {0} \"{1}\"{2}",
                                    TOCUser.Normalize(strUser), Encode(strMsg),
                                    bAuto ? " auto" : "");
            Send(strText);
        }
Пример #2
0
        public string [] GetConfigBuddies(string strConfig)
        {
            ArrayList names = new ArrayList();

            foreach (string strLine in strConfig.Split('\n'))
            {
                if (strLine.StartsWith("b"))
                {
                    string strTemp = strLine.Replace("\r", null);
                    int    i       = strTemp.IndexOf(" ", 0);
                    strTemp = strTemp.Remove(0, i + 1);
                    names.Add(TOCUser.Normalize(strTemp));
                }
            }

            return((string [])names.ToArray(typeof(string)));
        }
Пример #3
0
 public void Connect(string strName, string strPW)
 {
     user = new TOCUser(strName, strPW);
     Connect();
 }
Пример #4
0
        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 "CONFIG":
                if (AutoAddBuddies)
                {
                    AddBuddies(GetConfigBuddies(strArray[2]));
                }
                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_IN":
                if (OnIMIn != null)
                {
                    string strMsg = string.Join("", strArray, 6, strArray.Length - 6);
                    OnIMIn(TOCUser.Normalize(strArray[2]),
                           Regex.Replace(strMsg, @"<(.|\n)*?>", string.Empty), strArray[4] == "T");
                }
                break;

            case "UPDATE_BUDDY":
                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;

            default:
                break;
            }
        }
Пример #5
0
 public TOC(string strName, string strPW)
 {
     user = new TOCUser(strName, strPW);
 }
Пример #6
0
 public TOC()
 {
     user = new TOCUser();
 }