示例#1
0
 private void SendMessage()
 {
     try
     {
         if (chatBox.Text.ToLower().StartsWith("/whisper"))
         {
             string[] text = chatBox.Text.Split('"', '"');
             try
             {
                 user.CreateWhisper(text[3], TagColor, text[1]);
                 print(nameBox.Text + ": " + "Message privately sent to " + text[1], Chat, NColorToColor(TagColor));
             }
             catch (Exception ex)
             {
                 print("Couldn't run command", Chat, Color.Red);
                 PrintToLog("Couldn't run command -> " + ex.Message, Color.Red);
             }
         }
         else if (chatBox.Text.StartsWith("/color"))
         {
             string[] text = chatBox.Text.Replace("/color ", "").Split(' ');
             if (text.Length > 1)
             {
                 TagColor = NColor.FromRGB(int.Parse(text[0]), int.Parse(text[1]), int.Parse(text[2]));
             }
             else
             {
                 TagColor = ColorToNColor(Color.FromName(text[0]));
             }
         }
         else if (chatBox.Text.StartsWith("/info"))
         {
             string[] command = chatBox.Text.Replace("/info ", "").Split(' ');
             if (command[0] == "users")
             {
                 user.CreateInformation(InfomationType.ConnectedUsers);
             }
             else if (command[0] == "time")
             {
                 user.CreateInformation(InfomationType.ConnectTime);
             }
             else if (command[0] == "sent")
             {
                 user.CreateInformation(InfomationType.MessagesSent);
             }
             else if (command[0] == "uptime")
             {
                 user.CreateInformation(InfomationType.ServerUptime);
             }
             else if (command[0] == "rooms")
             {
                 user.CreateInformation(InfomationType.Rooms);
             }
             else
             {
                 print("Unknown Parameter", Chat);
             }
         }
         else if (chatBox.Text.StartsWith("/changeroom"))
         {
             string room = chatBox.Text.Replace("/changeroom ", "");
             user.CreateStatus(StatusType.ChangeRoom, room);
         }
         else
         {
             if (user != null)
             {
                 print(nameBox.Text + ": " + chatBox.Text, Chat, NColorToColor(TagColor));
                 user.CreateMessage(chatBox.Text, TagColor);
             }
         }
     }
     catch (Exception ex)
     {
         print("Error Sending Message -> " + ex.Message, Log, Color.Red);
     }
     chatBox.Clear();
 }