static bool ConvertLine(string line, out LoggedChat convertedLine) { convertedLine = null; string[] split = line.Split(','); if (split.Length < 3) { return(false); } DateTime timeStamp; Util.ChatChannels chatType; if (split[0].Contains("/")) { if (!DateTime.TryParseExact(split[0], "yy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeStamp)) { return(false); } chatType = (Util.ChatChannels)Enum.Parse(typeof(Util.ChatChannels), split[1]); } else { if (!DateTime.TryParseExact(split[0], "yyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeStamp)) { return(false); } int chatTypeInt; if (!int.TryParse(split[1], out chatTypeInt)) { return(false); } chatType = (Util.ChatChannels)chatTypeInt; } string message = line.Substring(split[0].Length + 1 + split[1].Length + 1, line.Length - (split[0].Length + 1 + split[1].Length + 1)); convertedLine = new LoggedChat(timeStamp, chatType, message); return(true); }
void logger_LogItem(LoggedChat item) { if (!Settings.SettingsManager.ChatLogger.Persistent.Value) { return; } Util.ChatChannels chatChannels = Util.ChatChannels.None; foreach (var group in Settings.SettingsManager.ChatLogger.Groups) { if (group.Area.Value) { chatChannels |= Util.ChatChannels.Area; } if (group.Tells.Value) { chatChannels |= Util.ChatChannels.Tells; } if (group.Fellowship.Value) { chatChannels |= Util.ChatChannels.Fellowship; } if (group.General.Value) { chatChannels |= Util.ChatChannels.General; } if (group.Trade.Value) { chatChannels |= Util.ChatChannels.Trade; } if (group.Allegiance.Value) { chatChannels |= Util.ChatChannels.Allegiance; } } if ((chatChannels & item.ChatType) != 0) { items.Add(item); } }
void logger_LogItem(LoggedChat item) { if (!Settings.SettingsManager.ChatLogger.Persistent.Value) return; Util.ChatChannels chatChannels = Util.ChatChannels.None; foreach (var group in Settings.SettingsManager.ChatLogger.Groups) { if (group.Area.Value) chatChannels |= Util.ChatChannels.Area; if (group.Tells.Value) chatChannels |= Util.ChatChannels.Tells; if (group.Fellowship.Value) chatChannels |= Util.ChatChannels.Fellowship; if (group.General.Value) chatChannels |= Util.ChatChannels.General; if (group.Trade.Value) chatChannels |= Util.ChatChannels.Trade; if (group.Allegiance.Value) chatChannels |= Util.ChatChannels.Allegiance; } if ((chatChannels & item.ChatType) != 0) items.Add(item); }
static bool ConvertLine(string line, out LoggedChat convertedLine) { convertedLine = null; string[] split = line.Split(','); if (split.Length < 3) return false; DateTime timeStamp; Util.ChatChannels chatType; if (split[0].Contains("/")) { if (!DateTime.TryParseExact(split[0], "yy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeStamp)) return false; chatType = (Util.ChatChannels)Enum.Parse(typeof(Util.ChatChannels), split[1]); } else { if (!DateTime.TryParseExact(split[0], "yyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeStamp)) return false; int chatTypeInt; if (!int.TryParse(split[1], out chatTypeInt)) return false; chatType = (Util.ChatChannels)chatTypeInt; } string message = line.Substring(split[0].Length + 1 + split[1].Length + 1, line.Length - (split[0].Length + 1 + split[1].Length + 1)); convertedLine = new LoggedChat(timeStamp, chatType, message); return true; }