예제 #1
0
 public void WriteMessage(ChatMessage message, bool autoscroll)
 {
     if (InvokeRequired)
     {
         Invoke(new Action<ChatMessage,bool>(WriteMessage), message,autoscroll);
     }
     else
     {
         ChatHelper.WriteMessage(message, _chatLog, autoscroll);
     }
 }
예제 #2
0
        public void WriteMessage(ChatMessage message)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<ChatMessage>(WriteMessage), message);
            }
            else
            {
                ChatHelper.WriteMessage(message, ChatLog, true);

                if(message.from != null)
                    if(message.from.username != Program.UserInfo.username && !ChatInput.Focused)
                        FlashWindow.Start(this);
            }
        }
예제 #3
0
        public static void WriteMessage(ChatMessage message, CustomRTB window, bool autoscroll)
        {
            if (window.Text != "")//start a new line unless theres no text
                window.AppendText(Environment.NewLine);
            window.Select(window.TextLength, 0);

            if ((CommandType)message.command == CommandType.Me)
            {
                string LogFile = "";
                string LogText = "";
                string LogDir = @"Logs\";
                if ((MessageType)message.type == MessageType.Message)
                {
                    LogFile = message.channel + DateTime.Now.ToString(".dd") + ".txt";
                    LogText += "[" + DateTime.Now.ToLongTimeString() + "] ";
                    LogDir += @"Channel\" + DateTime.Now.ToString("MMMM_yyyy") + @"\";
                }
                else if ((MessageType)message.type == MessageType.PrivateMessage)
                {
                    LogFile = message.channel + ".txt";
                    LogText += "[" + DateTime.Now + "] ";
                    LogDir += @"PMs\";
                }
                else if ((MessageType)message.type == MessageType.Team)
                {
                    LogFile = "Team.txt";
                    LogText += "[" + DateTime.Now.ToLongTimeString() + "] ";
                }
                if (Program.Config.ShowTimeStamp)
                {
                    WriteText(window, "[" + DateTime.Now.ToLongTimeString() + "] ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                if (message.from.usertag != "" || message.from.rank > 0 && message.from.rank < 99)
                {
                    WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));

                    LogText += "[";
                    string text = "";
                    switch (message.from.rank)
                    {
                        case 1:
                            text = "Helper";
                            break;

                        case 2:
                            text = "TD";
                            break;

                        case 3:
                            text = "Mod";
                            break;

                        case 4:
                            text = "SMod";
                            break;

                        case 98:
                            text = "Bot";
                            break;
                        default:
                            text = message.from.usertag;
                            break;
                            /*
                            case 99:
                                text = "Dev";
                                break;
                                */
                    }
                    LogText += text;
                    LogText += "]";

                    WriteText(window, text, (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));

                    WriteText(window, "]", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, message.message, Program.Config.MeMsgColor.ToColor());
                LogText += message.message.Trim();
                if (LogFile != "")
                    if (!Directory.Exists(LogDir))
                        Directory.CreateDirectory(LogDir);
                File.AppendAllText(LogDir + LogFile, LogText + Environment.NewLine);
            }
            else if ((MessageType)message.type == MessageType.Team && (CommandType)message.command == CommandType.TeamServerMessage)
            {
                WriteText(window, "[" + DateTime.Now.ToLongTimeString() + "] " + "[TeamMessage] " + message.message, (Program.Config.ColorBlindMode ? Color.Black : Program.Config.ServerMsgColor.ToColor()));
            }
            else if ((MessageType)message.type == MessageType.Message || (MessageType)message.type == MessageType.PrivateMessage || (MessageType)message.type == MessageType.Team)
            {
                string LogText = "";
                if (Program.Config.ShowTimeStamp)
                {
                    WriteText(window, "[" + DateTime.Now.ToLongTimeString() + "] ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                if (message.from.usertag != "" || message.from.rank > 0 && message.from.rank < 99)
                {
                    WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));

                    LogText += "[";
                    string text = "";
                    text = message.from.usertag;
                    //switch (message.from.rank)
                    //{
                    //    case 1:
                    //        text = "Helper";
                    //        break;

                    //    case 2:
                    //        text = "TD";
                    //        break;

                    //    case 3:
                    //        text = "Mod";
                    //        break;

                    //    case 4:
                    //        text = "SMod";
                    //        break;

                    //    case 98:
                    //        text = "Bot";
                    //        break;
                    //    default:
                    //        text = message.from.usertag;
                    //        break;
                    //        /*   case 99:
                    //               text = "Dev";
                    //               break; */
                    //}
                    LogText += text;
                    LogText += "]";

                    WriteText(window, text, (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));

                    WriteText(window, "]", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                if (Program.Config.UsernameColors)
                {
                    if (message.from.getUserColor().ToArgb() == Color.Black.ToArgb())
                    {
                        WriteText(window, message.from.username,
                            (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                    }
                    else
                    {
                        WriteText(window, message.from.username,
                            (Program.Config.ColorBlindMode ? Color.Black : message.from.getUserColor()));
                    }
                }
                else
                {
                    WriteText(window, message.from.username,
                        (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                }
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));

                //if (message.from.rank == 0)
                WriteText(window, message.message.Trim(), (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
                //else
                //    FormatText(message.message.Trim(), window);
                string LogFile = "";
                string LogDirectory = @"Logs\";
                if ((MessageType)message.type == MessageType.Message)
                {
                    LogDirectory += @"Channel\" + DateTime.Now.ToString("MMMM_yyyy") + @"\";
                    LogText = "[" + DateTime.Now.ToLongTimeString() + "] " + LogText;
                    LogFile = message.channel + DateTime.Now.ToString(".dd") + ".txt";
                }
                else if ((MessageType)message.type == MessageType.PrivateMessage)
                {
                    LogDirectory += @"PMs\"; ;
                    LogText = "[" + DateTime.Now + "] " + LogText;
                    LogFile = message.channel + ".txt";
                }
                else if ((MessageType)message.type == MessageType.Team)
                    LogFile = "Team.txt";
                LogText += "[" + message.from.username + "] " + message.message.Trim();
                if (LogFile != "")
                    if (!Directory.Exists(LogDirectory))
                        Directory.CreateDirectory(LogDirectory);
                File.AppendAllText(LogDirectory + LogFile, LogText + Environment.NewLine);
            }
            else if ((MessageType)message.type == MessageType.System || (MessageType)message.type == MessageType.Server || (MessageType)message.type == MessageType.MOTD)
            {
                if (Program.Config.ShowTimeStamp)
                {
                    WriteText(window, "[" + DateTime.Now.ToLongTimeString() + "] ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                WriteText(window, ((MessageType)message.type).ToString(), (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                WriteText(window, message.message, (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
            }
            else
            {
                WriteText(window, (Program.Config.ColorBlindMode ? "[" + (MessageType)message.type + "] " + message.message : message.message),
                    (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
            }

            //window.SelectionStart = window.TextLength;
            //window.SelectionLength = 0;

            if (autoscroll)
                window.ScrollToCaret();
        }
예제 #4
0
        public void WriteMessage(ChatMessage message)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<ChatMessage>(WriteMessage), message);
                return;
            }

            if(message.from != null && IgnoreUser(message.from))
            {
                return;
            }

            ChatWindow window;
            if ((MessageType)message.type == MessageType.Server || (MessageType)message.type == MessageType.System)
            {
                window = (ChatWindow)ChannelTabs.SelectedTab;
                if (window == null)
                {
                    window = new ChatWindow(((MessageType)message.type).ToString(), true) { IsSystemtab = true };
                    ChannelTabs.TabPages.Add(window);
                    window.WriteMessage(message, Autoscroll);
                }
                else window.WriteMessage(message, Autoscroll);
            }
            else if ((MessageType)message.type == MessageType.Join || (MessageType)message.type == MessageType.Leave || message.channel == null)
            {
                window = GetChatWindow(message.channel) ?? (ChatWindow)ChannelTabs.SelectedTab;
                if (window == null)
                {
                    window = new ChatWindow(message.type.ToString(CultureInfo.InvariantCulture), true) { IsSystemtab = true };
                    ChannelTabs.TabPages.Add(window);
                    window.WriteMessage(message, Autoscroll);
                }
                else window.WriteMessage(message, Autoscroll);
            }
            else if ((MessageType)message.type == MessageType.PrivateMessage && Program.Config.PmWindows)
            {
                if (m_pmWindows.ContainsKey(message.channel))
                {
                    m_pmWindows[message.channel].WriteMessage(message);
                }
                else
                {
                    m_pmWindows.Add(message.channel, new PmWindowFrm(message.channel, true));
                    m_pmWindows[message.channel].WriteMessage(message);
                    m_pmWindows[message.channel].Show();
                    m_pmWindows[message.channel].FormClosed += Chat_frm_FormClosed;
                }
            }
            else if ((MessageType)message.type == MessageType.Team)
            {
                window = GetChatWindow(((MessageType)message.type).ToString());
                if (window == null)
                {
                    window = new ChatWindow(((MessageType)message.type).ToString(), (MessageType)message.type == MessageType.PrivateMessage);
                    ChannelTabs.TabPages.Add(window);
                    window.WriteMessage(message, Autoscroll);
                }
                else window.WriteMessage(message, Autoscroll);
            }
            else
            {
                window = GetChatWindow(message.channel);
                if (window == null)
                {
                    window = new ChatWindow(message.channel, (MessageType)message.type == MessageType.PrivateMessage);
                    ChannelTabs.TabPages.Add(window);
                }

                window.WriteMessage(message, Autoscroll);
            }
        }
예제 #5
0
        public static void WriteMessage(ChatMessage message, CustomRTB window, bool autoscroll)
        {
            if (window.Text != "")//start a new line unless theres no text
                window.AppendText(Environment.NewLine);
            window.Select(window.TextLength, 0);

            if ((CommandType)message.command == CommandType.Me)
            {
                string LogFile = "";
                string LogText = "";
                string LogDir = @"Logs\";
                if ((MessageType)message.type == MessageType.Message)
                {
                    LogFile = message.channel + DateTime.Now.ToString(".dd") + ".txt";
                    LogText += DateTime.Now.ToString("[HH:mm] ");
                    LogDir += @"Channel\" + DateTime.Now.ToString("MMMM_yyyy") + @"\";
                }
                else if ((MessageType)message.type == MessageType.PrivateMessage)
                {
                    LogFile = message.channel + ".txt";
                    LogText += DateTime.Now.ToString("[dd/MM/yy | HH:mm] ");
                    LogDir += @"PMs\";
                }
                else if ((MessageType)message.type == MessageType.Team)
                {
                    LogFile = "Team.txt";
                    LogText += DateTime.Now.ToString("[HH:mm] ");
                }
                if (Program.Config.ShowTimeStamp)
                {
                    WriteText(window, DateTime.Now.ToString("[HH:mm] "), (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                if (message.from.rank > 0)
                {
                    WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                    if (message.from.rank == 1 || message.from.rank == 4)
                    {
                        WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                        LogText += "[Dev]";
                    }
                    else if (message.from.rank == 2 || message.from.rank == 3)
                    {
                        WriteText(window, "Mod", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                        LogText += "[Mod]";
                    }
                    else if (message.from.rank == 99)
                    {
                        LogText += "[Dev]";
                        WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                    }
                    WriteText(window, "]", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, message.message, Program.Config.MeMsgColor.ToColor());
                LogText += message.message.Trim();
                if (LogFile != "")
                    if (!Directory.Exists(LogDir))
                        Directory.CreateDirectory(LogDir);
                File.AppendAllText(LogDir + LogFile, LogText + Environment.NewLine);
            }
            else if ((MessageType)message.type == MessageType.Team && (CommandType)message.command == CommandType.TeamServerMessage)
            {
                WriteText(window, DateTime.Now.ToString("[HH:mm]") + "[TeamMessage] " + message.message,(Program.Config.ColorBlindMode ? Color.Black : Program.Config.ServerMsgColor.ToColor()));
            }
            else if ((MessageType)message.type == MessageType.Message || (MessageType)message.type == MessageType.PrivateMessage || (MessageType)message.type == MessageType.Team)
            {
                string LogText = "";
                if (Program.Config.ShowTimeStamp)
                {
                    WriteText(window, DateTime.Now.ToString("[HH:mm] "), (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                if (message.from.rank > 0)
                {
                    WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                    if (message.from.rank == 1 || message.from.rank == 4)
                    {
                        WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                        LogText += "[Dev]";
                    }
                    else if (message.from.rank == 2 || message.from.rank == 3)
                    {
                        WriteText(window, "Mod", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                        LogText += "[Mod]";
                    }
                    else if (message.from.rank == 99)
                    {
                        LogText += "[Dev]";
                        WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                    }
                    WriteText(window, "]", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                if (Program.Config.UsernameColors)
                {
                    if (message.from.getUserColor().ToArgb() == Color.Black.ToArgb())
                    {
                        WriteText(window, message.from.username,
                            (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                    }
                    else
                    {
                        WriteText(window, message.from.username,
                            (Program.Config.ColorBlindMode ? Color.Black : message.from.getUserColor()));
                    }
                }
                else
                {
                    WriteText(window, message.from.username,
                        (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                }
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));

                //if (message.from.rank == 0)
                    WriteText(window, message.message.Trim(), (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
                //else
                //    FormatText(message.message.Trim(), window);
                string LogFile = "";
                string LogDirectory = @"Logs\";
                if ((MessageType)message.type == MessageType.Message)
                {
                    LogDirectory += @"Channel\" + DateTime.Now.ToString("MMMM_yyyy") + @"\";
                    LogText = DateTime.Now.ToString("[HH:mm] ") + LogText;
                    LogFile = message.channel + DateTime.Now.ToString(".dd") + ".txt";
                }
                else if ((MessageType)message.type == MessageType.PrivateMessage)
                {
                    LogDirectory += @"PMs\"; ;
                    LogText = DateTime.Now.ToString("[dd/MM/yy | HH:mm] ") + LogText;
                    LogFile = message.channel + ".txt";
                }
                else if ((MessageType)message.type == MessageType.Team)
                    LogFile = "Team.txt";
                LogText += "[" + message.from.username + "] " + message.message.Trim();
                if (LogFile != "")
                    if (!Directory.Exists(LogDirectory))
                        Directory.CreateDirectory(LogDirectory);
                    File.AppendAllText(LogDirectory + LogFile, LogText + Environment.NewLine);

            }
            else if ((MessageType)message.type == MessageType.System || (MessageType)message.type == MessageType.Server)
            {
                if (Program.Config.ShowTimeStamp)
                {
                    WriteText(window, DateTime.Now.ToString("[HH:mm] "), (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window,"[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                WriteText(window, ((MessageType)message.type).ToString() ,(Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                WriteText(window, message.message, (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
            }
            else
            {
                WriteText(window, (Program.Config.ColorBlindMode ? "[" + (MessageType)message.type + "] " + message.message : message.message),
                    (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
            }

            //window.SelectionStart = window.TextLength;
            //window.SelectionLength = 0;

            if (autoscroll)
                window.ScrollToCaret();
        }
예제 #6
0
        public static void WriteMessage(ChatMessage message, CustomRTB window,bool autoscroll)
        {
            if (window.Text != "")//start a new line unless theres no text
                window.AppendText(Environment.NewLine);
            window.Select(window.TextLength, 0);

            if ((CommandType)message.command == CommandType.Me)
            {
                WriteText(window, message.message, Program.Config.MeMsgColor.ToColor());
            }
            else if ((MessageType)message.type == MessageType.Team && (CommandType)message.command == CommandType.TeamServerMessage)
            {
                WriteText(window, "[TeamMessage] " + message.message,(Program.Config.ColorBlindMode ? Color.Black : Program.Config.ServerMsgColor.ToColor()));
            }
            else if ((MessageType)message.type == MessageType.Message || (MessageType)message.type == MessageType.PrivateMessage || (MessageType)message.type == MessageType.Team)
            {
                if (Program.Config.ShowTimeStamp)
                    WriteText(window, DateTime.Now.ToString("[HH:mm] "), (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                if (message.from.rank > 0)
                {
                    WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                    if (message.from.rank == 1 || message.from.rank == 4)
                        WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                    else if (message.from.rank == 2 || message.from.rank == 3)
                        WriteText(window, "Mod", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                    else if (message.from.rank == 99)
                        WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor()));
                    WriteText(window, "]", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                if (Program.Config.UsernameColors)
                {
                    if (message.from.getUserColor().ToArgb() == Color.Black.ToArgb())
                    {
                        WriteText(window, message.from.username,
                            (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                    }
                    else
                    {
                        WriteText(window, message.from.username,
                            (Program.Config.ColorBlindMode ? Color.Black : message.from.getUserColor()));
                    }
                }
                else
                {
                    WriteText(window, message.from.username,
                        (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                }
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));

                if (message.from.rank == 0)
                    WriteText(window, message.message.Trim(), (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
                else
                    FormatText(message.message.Trim(), window);

            }
            else if ((MessageType)message.type == MessageType.System || (MessageType)message.type == MessageType.Server)
            {
                WriteText(window,"[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                WriteText(window, ((MessageType)message.type).ToString() ,(Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                WriteText(window, message.message, (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
            }
            else
            {
                WriteText(window, (Program.Config.ColorBlindMode ? "[" + (MessageType)message.type + "] " + message.message : message.message),
                    (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor()));
            }

            window.SelectionStart = window.TextLength;
            window.SelectionLength = 0;

            if (autoscroll)
                window.ScrollToCaret();
        }