public static void HandleCommands(ChatLogEntry chatLogEntry) { // process commands if (chatLogEntry.Code == "0038") { var commandsRegEx = CommandBuilder.CommandsRegEx.Match(chatLogEntry.Line.Trim()); if (commandsRegEx.Success) { var plugin = commandsRegEx.Groups["plugin"].Success ? commandsRegEx.Groups["plugin"].Value : ""; var command = commandsRegEx.Groups["command"].Success ? commandsRegEx.Groups["command"].Value : ""; switch (plugin) { case "parse": switch (command) { case "on": IsPaused = false; break; case "off": IsPaused = true; break; case "reset": ParseControl.Instance.Reset(); break; } break; } } } }
// battle data public Line(ChatLogEntry chatLogEntry = null) { if (chatLogEntry != null) { ChatLogEntry = chatLogEntry; } }
public static ChatLogEntry Process(byte[] raw) { var chatLogEntry = new ChatLogEntry(); try { chatLogEntry.Bytes = raw; chatLogEntry.TimeStamp = DateTimeHelper.UnixTimeStampToDateTime(Int32.Parse(ByteArrayToString(raw.Take(4) .Reverse() .ToArray()), NumberStyles.HexNumber)); chatLogEntry.Code = ByteArrayToString(raw.Skip(4) .Take(2) .Reverse() .ToArray()); chatLogEntry.Raw = Encoding.UTF8.GetString(raw.ToArray()); var cleanable = raw.Skip(8) .ToArray(); var cleaned = new ChatCleaner(cleanable).Result; var cut = (cleaned.Substring(1, 1) == ":") ? 2 : 1; chatLogEntry.Line = XmlHelper.SanitizeXmlString(cleaned.Substring(cut)); chatLogEntry.Line = new ChatCleaner(chatLogEntry.Line).Result; chatLogEntry.JP = Encoding.UTF8.GetBytes(chatLogEntry.Line) .Any(b => b > 128); chatLogEntry.Combined = String.Format("{0}:{1}", chatLogEntry.Code, chatLogEntry.Line); } catch (Exception ex) { chatLogEntry.Bytes = new byte[0]; chatLogEntry.Raw = ""; chatLogEntry.Line = ""; chatLogEntry.Code = ""; chatLogEntry.Combined = ""; } return chatLogEntry; }
public static void Process(ChatLogEntry chatLogEntry) { try { } catch (Exception ex) { } }
public static void Process(ChatLogEntry chatEntry) { try { } catch (Exception ex) { LogHelper.Log(Logger, ex, LogLevel.Error); } }
public void RaiseNewChatLogEntry(ChatLogEntry chatLogEntry) { if (ChatLogWorkerDelegate.IsPaused) { return; } AppViewModel.Instance.ChatHistory.Add(chatLogEntry); // THIRD PARTY PluginHost.Instance.RaiseNewChatLogEntry(chatLogEntry); }
public static void Process(ChatLogEntry chatLogEntry) { try { if (TwintaniaWidgetViewModel.Instance.TwintaniaIsValid) { var line = chatLogEntry.Line.Replace(" ", " "); var name = TwintaniaWidgetViewModel.Instance.TwintaniaEntity.Name; switch (chatLogEntry.Code) { case "2AAB": if (Regex.IsMatch(line, @"(?i)^\s*.*" + name + @".*(" + string.Join("|", divebomb.Select(Regex.Escape) .ToArray()) + @")")) { TwintaniaWidgetViewModel.Instance.TriggerDiveBomb(); } else if (Regex.IsMatch(line, @"(?i)^\s*.*" + name + @".*(" + string.Join("|", twister.Select(Regex.Escape) .ToArray()) + @")")) { TwintaniaWidgetViewModel.Instance.TriggerTwister(); } else { LogHelper.Log(Logger, "Chat Code " + chatLogEntry.Code + " received - did not match twister or divebomb. Twintania's recorded name:" + name + " Message:" + line, LogLevel.Debug); } break; case "292B": case "312B": case "28AB": if (Regex.IsMatch(line, @"(?i)^\s*.*" + name + @".*(" + string.Join("|", deathsentence.Select(Regex.Escape) .ToArray()) + @")")) { TwintaniaWidgetViewModel.Instance.TriggerDeathSentence(); } else { LogHelper.Log(Logger, "Chat Code " + chatLogEntry.Code + " received - did not death sentence. Twintania's recorded name:" + name + " Message:" + line, LogLevel.Debug); } break; } } } catch (Exception ex) { LogHelper.Log(Logger, ex, LogLevel.Error); } }
public static void Process(ChatLogEntry chatLogEntry) { try { var line = chatLogEntry.Line.Replace(" ", " "); foreach (var item in PluginViewModel.Instance.Events) { if (!item.Enabled) { continue; } var resuccess = false; var check = new Regex(item.RegEx); if (SharedRegEx.IsValidRegex(item.RegEx)) { var reg = check.Match(line); if (reg.Success) { resuccess = true; } } else { resuccess = (item.RegEx == line); } if (!resuccess) { continue; } var soundEvent = item; Func<bool> playSound = delegate { var delay = soundEvent.Delay; var timer = new Timer(delay > 0 ? delay * 1000 : 1); ElapsedEventHandler timerEventHandler = null; timerEventHandler = delegate { DispatcherHelper.Invoke(() => SoundPlayerHelper.Play(Constants.BaseDirectory, soundEvent.Sound)); timer.Elapsed -= timerEventHandler; }; timer.Elapsed += timerEventHandler; timer.Start(); return true; }; playSound.BeginInvoke(null, null); } } catch (Exception ex) { Logging.Log(LogManager.GetCurrentClassLogger(), "", ex); } }
public static void Process(ChatLogEntry chatEntry) { try { var timeStampColor = Settings.Default.TimeStampColor.ToString(); var timeStamp = chatEntry.TimeStamp.ToString("[HH:mm:ss] "); var line = chatEntry.Line.Replace(" ", " "); var color = (Constants.Colors.ContainsKey(chatEntry.Code)) ? Constants.Colors[chatEntry.Code][0] : "FFFFFF"; FFXIVAPP.Common.Constants.FD.AppendFlow(timeStamp, "", line, new[] { timeStampColor, "#" + color }, MainView.View.ChatLogFD._FDR); } catch (Exception ex) { Logging.Log(LogManager.GetCurrentClassLogger(), "", ex); } }
public static void Process(ChatLogEntry chatLogEntry) { if (IsPaused) { return; } try { chatLogEntry.Line = chatLogEntry.Line.Replace(" ", " "); if (Constants.NeedGreed.Any(chatLogEntry.Line.Contains)) { NeedGreedHistory.Add(chatLogEntry.Line); } DispatcherHelper.Invoke(() => EventParser.Instance.ParseAndPublish(chatLogEntry)); HandleCommands(chatLogEntry); } catch (Exception ex) { } }
public virtual void RaiseNewChatLogEntry(ChatLogEntry e) { var chatLogEntryEvent = new ChatLogEntryEvent(this, e); var handler = NewChatLogEntry; if (handler != null) { handler(this, chatLogEntryEvent); } }
private void Initialize(DateTime timeStamp, EventCode eventCode, ChatLogEntry chatLogEntry) { Timestamp = timeStamp; EventCode = eventCode; ChatLogEntry = chatLogEntry; }
public Event(EventCode eventCode = null, ChatLogEntry chatLogEntry = null) { Initialize(DateTime.Now, eventCode, chatLogEntry); }
public static void HandleCommands(ChatLogEntry chatLogEntry) { }
private void ChatLogWorkerOnNewLine(ChatLogEntry chatLogEntry) { // delegate event from chat log, not required to subsribe try { LogPublisher.Process(chatLogEntry); } catch (Exception ex) { //Logging.Log(LogManager.GetCurrentClassLogger(), "", ex); MessageBox.Show(ex.Message); Notice = ex.Message; } }
public ChatLogEntryEvent(object sender, ChatLogEntry chatLogEntry) { Sender = sender; ChatLogEntry = chatLogEntry; }
/// <summary> /// </summary> /// <param name="chatLogEntry"></param> public void ParseAndPublish(ChatLogEntry chatLogEntry) { var @event = Parse(chatLogEntry); var eventHandler = @event.IsUnknown ? OnUnknownLogEvent : OnLogEvent; if (eventHandler == null) { return; } lock (eventHandler) { eventHandler(this, @event); } }
public static void Process(ChatLogEntry chatLogEntry) { try { // setup variables var timeStampColor = Settings.Default.TimeStampColor.ToString(); var timeStamp = chatLogEntry.TimeStamp.ToString("[HH:mm:ss] "); var line = chatLogEntry.Line.Replace(" ", " "); var rawLine = line; var color = (Constants.Colors.ContainsKey(chatLogEntry.Code)) ? Constants.Colors[chatLogEntry.Code][0] : "FFFFFF"; var isLS = Constants.Linkshells.ContainsKey(chatLogEntry.Code); line = isLS ? Constants.Linkshells[chatLogEntry.Code] + line : line; var playerName = ""; // handle tabs if (CheckMode(chatLogEntry.Code, Constants.ChatPublic)) { playerName = line.Substring(0, line.IndexOf(":", StringComparison.Ordinal)); line = line.Replace(playerName + ":", ""); } if (Settings.Default.EnableAll) { Common.Constants.FD.AppendFlow(timeStamp, playerName, line, new[] { timeStampColor, "#" + color }, MainView.View.AllFD._FDR); } DispatcherHelper.Invoke(delegate { foreach (var flowDoc in PluginViewModel.Instance.Tabs.Select(ti => (xFlowDocument) ((TabItem) ti).Content)) { var resuccess = false; var xRegularExpression = flowDoc.RegEx.Text; switch (xRegularExpression) { case "*": resuccess = true; break; default: try { var check = new Regex(xRegularExpression); if (SharedRegEx.IsValidRegex(xRegularExpression)) { var reg = check.Match(line); if (reg.Success) { resuccess = true; } } } catch { resuccess = true; } break; } if (resuccess && flowDoc.Codes.Items.Contains(chatLogEntry.Code)) { Common.Constants.FD.AppendFlow(timeStamp, playerName, line, new[] { timeStampColor, "#" + color }, flowDoc._FDR); } } }); // handle translation if (Settings.Default.EnableTranslate) { if (CheckMode(chatLogEntry.Code, Constants.ChatSay) && Settings.Default.TranslateSay) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatTell) && Settings.Default.TranslateTell) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatParty) && Settings.Default.TranslateParty) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatShout) && Settings.Default.TranslateShout) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatYell) && Settings.Default.TranslateYell) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatLS) && Settings.Default.TranslateLS) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatFC) && Settings.Default.TranslateFC) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } if (CheckMode(chatLogEntry.Code, Constants.ChatAlliance) && Settings.Default.TranslateAlliance) { Translate.GetAutomaticResult(rawLine, chatLogEntry.JP); } } // handle debug tab if (Settings.Default.ShowASCIIDebug) { var asciiString = ""; for (var j = 0; j < chatLogEntry.Bytes.Length; j++) { asciiString += chatLogEntry.Bytes[j].ToString(CultureInfo.CurrentUICulture) + " "; } asciiString = asciiString.Trim(); Common.Constants.FD.AppendFlow("", "", asciiString, new[] { "", "#FFFFFFFF" }, MainView.View.DebugFD._FDR); } if (Settings.Default.EnableDebug) { var raw = String.Format("{0}[{1}]{2}", chatLogEntry.Raw.Substring(0, 8), chatLogEntry.Code, chatLogEntry.Raw.Substring(12)); Common.Constants.FD.AppendFlow("", "", raw, new[] { "", "#FFFFFFFF" }, MainView.View.DebugFD._FDR); } } catch (Exception ex) { Logging.Log(LogManager.GetCurrentClassLogger(), "", ex); } }
/// <summary> /// </summary> /// <param name="chatLogEntry"></param> /// <returns></returns> private Event Parse(ChatLogEntry chatLogEntry) { EventCode eventCode; var code = Convert.ToUInt64(chatLogEntry.Code, 16); if (EventCodes.TryGetValue(code, out eventCode)) { return new Event(eventCode, chatLogEntry); } var unknownEventCode = new EventCode { Code = code }; return new Event(unknownEventCode, chatLogEntry); }