コード例 #1
0
        ChatMSG ExtractMessage(string rawMsg)
        {
            ChatMSG output = new ChatMSG(rawMsg);

            int nameIndex = rawMsg.IndexOf("display-name=") + "display-name=".Length;

            if (nameIndex > -1)
            {
                int nameEndIndex = rawMsg.IndexOf(";", nameIndex);
                output.name = rawMsg.Substring(nameIndex, nameEndIndex - nameIndex);
            }

            int colorIndex = rawMsg.IndexOf("color=") + "color=".Length;

            if (colorIndex > -1)
            {
                int    colorEndIndex = rawMsg.IndexOf(";", colorIndex);
                string color         = rawMsg.Substring(colorIndex, colorEndIndex - colorIndex);
                if (color == "")
                {
                    color = "#000000";
                }
                output.color = HexToColor(color);
            }

            int    messageIndex      = rawMsg.IndexOf("PRIVMSG");
            int    messageStartIndex = rawMsg.IndexOf(':', messageIndex) + 1;
            string msg = rawMsg.Substring(messageStartIndex);

            output.msg = msg;

            return(output);
        }
コード例 #2
0
        void SendCommand(string message)
        {
            byte[] buffer = Encoding.UTF8.GetBytes(message + "\r\n");
            socket.Send(buffer, buffer.Length, SocketFlags.None);

            ChatMSG cMSG = new ChatMSG(message, "", "", Color.Black);

            Console.WriteLine(message);
            form1.AddMessage(cMSG);
        }
コード例 #3
0
 public void GetIrcMessage(string message, bool fromClient = false)
 {
     if (fromClient == false)
     {
         if (message.Contains("PRIVMSG"))
         {
             form1.AddMessage(ExtractMessage(message));
         }
     }
     else
     {
         ChatMSG cMSG = new ChatMSG(message, userName, message, Color.Black);
         form1.AddMessage(cMSG);
     }
 }
コード例 #4
0
 public void AddMessage(ChatMSG msg)
 {
     chatMessages.Add(msg);
 }