private void LogServerMessage(ChatMessage message) { ChatLogEntry logEntry = new ChatLogEntry("Server", message.Text, new UnityEngine.Color32(0x8c, 0x00, 0xFF, 0xFF)); playerChat.WriteChatLogEntry(logEntry); playerChat.ShowLog(); }
public static string getCallerName(ChatLogEntry chatLogEntry) { String callerName = ""; MatchCollection calMatched = Regex.Matches(chatLogEntry.Line, HuntsRegEx.CallerNameRegEx); foreach (Match match in calMatched) { callerName = match.Groups[1].Value; } return(callerName); }
private static String getSource(ChatLogEntry entry) { switch (entry.Code) { case "000A": return("Say"); case "000B": return("Shout"); case "000E": return("Party"); case "000C": case "000D": return("Tell"); case "0010": return("LS1"); case "0011": return("LS2"); case "0012": return("LS3"); case "0013": return("LS4"); case "0014": return("LS5"); case "0015": return("LS6"); case "0016": return("LS7"); case "0017": return("LS8"); case "0018": return("FC"); case "001E": return("Yell"); /*case "0039": // This should be removed after any debugging * return "Echo";*/ default: return("Unknown"); } }
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 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 HuntZoneLocation getLocation(ChatLogEntry chatLogEntry) { MatchCollection LocMatched = Regex.Matches(chatLogEntry.Line, HuntsRegEx.MapLocationRegEx); foreach (Match match in LocMatched) { String Zone = match.Groups[1].Value; Int32 X = System.Convert.ToInt32(match.Groups[2].Value); Int32 Y = System.Convert.ToInt32(match.Groups[3].Value); return(new HuntZoneLocation(Zone, X, Y)); } return(new HuntZoneLocation()); }
public static HuntZoneLocation getLocation(ChatLogEntry chatLogEntry, String Zone) { String LocRegex = String.Format(HuntsRegEx.MapLocationZoneRegEx, Zone); MatchCollection LocMatched = Regex.Matches(chatLogEntry.Line, LocRegex); foreach (Match match in LocMatched) { Int32 X = System.Convert.ToInt32(match.Groups[1].Value); Int32 Y = System.Convert.ToInt32(match.Groups[2].Value); return(new HuntZoneLocation(Zone, X, Y)); } return(new HuntZoneLocation()); }
/// <summary> /// Takes a new chat message and displays that message along with MESSAGE_LIMIT-1 previous entries for /// CHAT_VISIBILITY_TIME_LENGTH seconds /// </summary> /// <param name="chatLogEntry"></param> public void WriteEntry(ChatLogEntry chatLogEntry) { if (timer != null) { // cancel hiding chat entries because a new one was recently posted StopCoroutine(timer); } chatLogEntry.MessageText = SanitizeMessage(chatLogEntry.MessageText); AddChatMessage(chatLogEntry); BuildChatText(); timer = StartCoroutine(DeactivateChat()); }