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(); } }
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 || (MessageType)message.type == MessageType.MOTD) { 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(); } }
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(); } }