コード例 #1
0
ファイル: Client.cs プロジェクト: sonicwang1989/lphant
        public void ProcessChatMessage(byte[] packet)
        {
            if(m_FriendLevel==Constants.FriendLevel.NoFriend && CKernel.Preferences.GetBool("ReceiveMessageFromFriendOnly")) return;

            CClientMessage ClientMessage=new CClientMessage(new MemoryStream(packet));

            //Do not diplay spam
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("http://")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("ed2k://")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("www")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("sex")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("p**n")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("crack")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("virus")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("troyen")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("no up")>=0) m_IsSpammer=true;
            if (m_FirstMessage && ClientMessage.Message.ToLower().IndexOf("noup")>=0) m_IsSpammer=true;
            if (m_IsSpammer) return;

            //filter automated messages
            bool filtered=false;
            if (ClientMessage.Message.ToLower().IndexOf("automated message")>=0) filtered=true;
            if (ClientMessage.Message.ToLower().IndexOf("automated warning")>=0) filtered=true;
            if (ClientMessage.Message.ToLower().IndexOf("your client has an infinite queue")>=0) filtered=true;
            if (ClientMessage.Message.ToLower().IndexOf("automessage")>=0) filtered=true;
            if (ClientMessage.Message.ToLower().IndexOf("banreason")>=0) filtered=true;
            if (ClientMessage.Message.ToLower().IndexOf("auto message")>=0) filtered=true;
            if (filtered)
            {
                CKernel.Queue.RemoveClient(this);
                return;
            }
            CKernel.NewChatMessage(this,ClientMessage.Message);
            m_FirstMessage=false;
            Debug.WriteLine(ClientMessage.Message);
        }
コード例 #2
0
ファイル: Client.cs プロジェクト: sonicwang1989/lphant
 public void SendChatMessage(string message)
 {
     if (connection!=null)
     {
         CClientMessage ClientMessage;
         MemoryStream buffer;
         if ((m_ChatMessages!=null))
         {
             foreach (string msg in m_ChatMessages)
             {
                 buffer=new MemoryStream();
                 ClientMessage=new CClientMessage(buffer,msg);
                 connection.SendPacket(buffer);
             }
             m_ChatMessages.Clear();
             m_ChatMessages=null;
         }
         buffer=new MemoryStream();
         if (message.Length>0)
         {
             ClientMessage=new CClientMessage(buffer,message);
             connection.SendPacket(buffer);
         }
     }
     else
     {
         if (m_ChatMessages==null) m_ChatMessages=new StringCollection();
         m_ChatMessages.Add(message);
         Connect();
     }
 }