/// <summary> /// Holds search criteria for scheduling log searches /// </summary> /// <param name="player"></param> /// <param name="gamelogtype"></param> /// <param name="timefrom"></param> /// <param name="timeto"></param> /// <param name="searchkey">null or empty string to indicate this requires no match search</param> /// <param name="searchtype"></param> internal SearchData(string player, GameLogTypes gamelogtype, DateTime timefrom, DateTime timeto, string searchkey, SearchTypes searchtype) { this.Player = player; this.GameLogType = gamelogtype; this.TimeFrom = timefrom; this.TimeTo = timeto; if (searchkey != null) this.SearchKey = searchkey; else this.SearchKey = ""; this.SearchType = searchtype; }
public void AddReset(string pattern, GameLogTypes logtype, bool isRegex) { var cond = ConditionFactory(pattern, logtype, isRegex); if (ResetConditions != null) { var x = ResetConditions.ToList(); x.Add(ConditionFactory(pattern, logtype, isRegex)); ResetConditions = x.ToArray(); } else ResetConditions = new Condition[] { cond }; }
public void AddTrigger(string pattern, GameLogTypes logtype, bool isRegex) { var cond = ConditionFactory(pattern, logtype, isRegex); if (TriggerConditions != null) { var x = TriggerConditions.ToList(); x.Add(cond); TriggerConditions = x.ToArray(); } else TriggerConditions = new Condition[] { cond }; }
Condition ConditionFactory(string pattern, GameLogTypes logtype, bool isRegex) { if (pattern == null) pattern = ""; pattern = pattern.Trim(); if (!isRegex) pattern = Regex.Escape(pattern); else IsRegex = true; Condition cond = new Condition(); cond.RegexPattern = pattern; cond.LogType = logtype; return cond; }
public virtual bool CheckLogType(GameLogTypes type) { return _logTypes.Contains(type); }
public void RemoveLogType(GameLogTypes type) { _logTypes.Remove(type); }
public void AddLogType(GameLogTypes type) { if (LogTypesLocked) throw new TriggerException("child has blocked adding log types to this trigger"); _logTypes.Add(type); }
internal void SetLogType(GameLogTypes logType, System.Windows.Forms.CheckState checkState) { if (checkState == CheckState.Checked) { AddLogType(logType); } else { RemoveLogType(logType); } }
//TODO modify to be handled with new wurm logs manager private void HandleNewLogEvents(List<string> newLogEvents, GameLogTypes logType) { List<PlaylistEntryCacheable> currentPlaylist; switch (logType) { case GameLogTypes.Event: currentPlaylist = EventPlaylist; break; case GameLogTypes.Combat: currentPlaylist = CombatPlaylist; break; case GameLogTypes.Alliance: currentPlaylist = AlliancePlaylist; break; case GameLogTypes.CA_HELP: currentPlaylist = CA_HELPPlaylist; break; case GameLogTypes.Freedom: currentPlaylist = FreedomPlaylist; break; case GameLogTypes.Friends: currentPlaylist = FriendsPlaylist; break; case GameLogTypes.GLFreedom: currentPlaylist = GLFreedomPlaylist; break; case GameLogTypes.Local: currentPlaylist = LocalPlaylist; break; case GameLogTypes.MGMT: currentPlaylist = MGMTPlaylist; break; case GameLogTypes.Skills: currentPlaylist = SkillsPlaylist; break; case GameLogTypes.Team: currentPlaylist = TeamPlaylist; break; case GameLogTypes.Village: currentPlaylist = VillagePlaylist; break; case GameLogTypes.PM: currentPlaylist = PMPlaylist; break; default: throw new Exception("No cached playlist for this log type: " + logType); } lastline = ""; foreach (string line in newLogEvents) { if (lastline != line) { Logger.LogDebug("> SoundNotify > HandleNewLogEvents > line processed"); // determine if queue sound should be played if (Settings.Value.QueueSoundEnabled && logType == GameLogTypes.Event) handleQueueSound(line); if (!Muted) { foreach (PlaylistEntryCacheable playlistentry in currentPlaylist) { if (playlistentry.isActive && playlistentry.Soundplayer != null && playlistentry.Condition != "" && Regex.IsMatch(line, playlistentry.Condition, RegexOptions.IgnoreCase)) { try { playlistentry.Soundplayer.Play(); Logger.LogInfo("Sound notify played sound: " + playlistentry.SoundName + " on event: " + line); } catch (FileNotFoundException _e) { Logger.LogInfo("Sound notify could not play sound " + playlistentry.SoundName + ", reason: " + _e.Message); } } } } } lastline = line; } }
/// <summary> /// returns null on error, filters out other server groups, /// min/max search date is unbound using this overload /// </summary> /// <param name="logType"></param> /// <param name="since">amount of time to look back, will accept any value</param> /// <returns></returns> protected async Task<List<string>> GetLogLinesFromLogHistoryAsync(GameLogTypes logType, TimeSpan since) { LogSearchData lgs = new LogSearchData(); lgs.SetSearchCriteria( Player, logType, DateTime.Now - since, DateTime.Now, "", SearchTypes.RegexEscapedCaseIns); lgs = await WurmLogSearcherAPI.SearchWurmLogsFilteredByServerGroupAsync(lgs, TargetServerGroup); return lgs.AllLines; }
public static string GetNameForLogType(GameLogTypes type) { return EnumToNameMap[type]; }
static void AddLogTypeMapping(string logName, GameLogTypes logType) { NameToEnumMap.Add(logName, logType); EnumToNameMap.Add(logType, logName); }
/// <summary> /// constructs new log wrapper, name required ONLY for PM logs /// </summary> /// <param name="wurmLogDirAddress">path to the Wurm Online Logs folder for chosen player account</param> /// <param name="logtype">type of this log, determines what files will be searched for aquiring</param> /// <param name="name">name of the PM player, if this is PM log wrapper</param> internal GameLogState(string wurmLogDirAddress, GameLogTypes logtype, bool dailyLoggingMode, string name = "") { this._logType = logtype; this.DailyLoggingMode = dailyLoggingMode; if (this._logType == GameLogTypes.PM) { this.pm_name = "__" + name; } this.logDirPath = wurmLogDirAddress; InitLogState(); }
public override bool CheckLogType(GameLogTypes type) { return type == GameLogTypes.Event; }
/// <summary> /// returns null on error, filters out other server groups /// min search 7 days ago, max search 120 days ago /// </summary> /// <param name="logType"></param> /// <param name="lastCheckup"></param> /// <returns></returns> protected async Task<List<string>> GetLogLinesFromLogHistoryAsync(GameLogTypes logType, DateTime lastCheckup) { return await GetLogLinesFromLogHistoryAsync(logType, HowLongAgoWasThisDate(lastCheckup)); }
private void HandleNewLogEvents(IEnumerable<string> newLogEvents, GameLogTypes logType) { _lastline = ""; var dtNow = DateTime.Now; foreach (string logMessage in newLogEvents) { if (logMessage != null && _lastline != logMessage && logMessage.Trim() != string.Empty) { Logger.LogDebug("log message forwarded", this); foreach (var trigger in Settings.Value.Triggers.ToArray()) { if (trigger.CheckLogType(logType)) { trigger.Update(logMessage, dtNow); } } _lastline = logMessage; } } }
/// <summary> /// Set the search criteria /// </summary> /// <param name="player">Player name, case sensitive</param> /// <param name="gamelogtype">Type of the log</param> /// <param name="timefrom">Begin date boundary</param> /// <param name="timeto">End date boundary</param> /// <param name="searchkey">Text to search for, or regex expression for regex search type</param> /// <param name="searchtype">Search type</param> /// <param name="PM_recipient"> /// In case this is PM-log search criteria, this should be the PM recipient name. /// Not supplying this value will result in a general PM search trough all conversations. /// </param> public void SetSearchCriteria(string player, GameLogTypes gamelogtype, DateTime timefrom, DateTime timeto, string searchkey, SearchTypes searchtype, string PM_recipient = null) { SearchCriteria = new SearchData(player, gamelogtype, timefrom, timeto, searchkey, searchtype); if (PM_recipient != null) this.SetPM_Player(PM_recipient); }