public static void Process(ChatLogEntry chatLogEntry) { try { Boolean widgetEnabled = Settings.Default.ShowHuntWidgetOnLoad; Boolean OneServiceEnabled = (widgetEnabled || Settings.Default.EnableNotifyMyAndroidService || Settings.Default.EnablePushoverService || Settings.Default.EnableGrowl); Boolean checkChats = (widgetEnabled || Settings.Default.EnablePushNotifications); /* If there is no services enabled, don't bother checking the chats. */ if (!checkChats || !OneServiceEnabled) { return; } if (getSource(chatLogEntry) != "Unknown") { Logging.Log(LogManager.GetCurrentClassLogger(), "Current Player: " + HuntsPublisher.currentPlayer); FoundHunt FoundHunt = IsMatched(chatLogEntry); switch (FoundHunt.rank) { case "A": if (!Settings.Default.EnableARankNotifications) { return; } break; case "S": if (!Settings.Default.EnableSRankNotifications) { return; } break; default: break; } if (FoundHunt.found) { PastHunts.Add(FoundHunt); if (Settings.Default.EnablePushNotifications) { SendPost(FoundHunt, chatLogEntry); } } } } catch (Exception ex) { Logging.Log(LogManager.GetCurrentClassLogger(), "", ex); } }
public static FoundHunt IsMatched(ChatLogEntry chatLogEntry) { Hashtable Hunts; ArrayList Zones; switch (Constants.GameLanguage) { case "French": Hunts = HuntsRegEx.HuntsFr; Zones = HuntsRegEx.validZonesFr; break; case "Japanese": Hunts = HuntsRegEx.HuntsJp; Zones = HuntsRegEx.validZonesJp; break; case "German": Hunts = HuntsRegEx.HuntsDe; Zones = HuntsRegEx.validZonesDe; break; default: Hunts = HuntsRegEx.HuntsEn; Zones = HuntsRegEx.validZonesEn; break; } foreach (string Name in HuntsRegEx.SHuntNames) { HuntEntry HuntData = (HuntEntry)Hunts[Name]; Regex HuntRegex = HuntData.regex; if (HuntRegex.IsMatch(chatLogEntry.Line)) { PastHunts.CheckSingle(Name); PastHunts.Check(); if (!PastHunts.AlreadySent(Name)) { String HuntName = Name; HuntZoneLocation CalledHuntLocation = getLocation(chatLogEntry, HuntData.location); String CalledHuntCallersName = getCallerName(chatLogEntry); String CalledSource = getSource(chatLogEntry); FoundHunt FoundHunt = new FoundHunt(HuntName, HuntData.translatedname, HuntData.rank, CalledHuntLocation, CalledHuntCallersName, CalledSource); return(FoundHunt); } else { //Logging.Log(LogManager.GetCurrentClassLogger(), "Already sent a notification for this hunt recently " + HuntName); return(new FoundHunt()); } } } foreach (string Name in HuntsRegEx.AHuntNames) { HuntEntry HuntData = (HuntEntry)Hunts[Name]; Regex HuntRegex = HuntData.regex; if (HuntRegex.IsMatch(chatLogEntry.Line)) { PastHunts.CheckSingle(Name); PastHunts.Check(); if (!PastHunts.AlreadySent(Name)) { String HuntName = Name; HuntZoneLocation CalledHuntLocation = getLocation(chatLogEntry, HuntData.location); String CalledHuntCallersName = getCallerName(chatLogEntry); String CalledSource = getSource(chatLogEntry); FoundHunt FoundHunt = new FoundHunt(HuntName, HuntData.translatedname, HuntData.rank, CalledHuntLocation, CalledHuntCallersName, CalledSource); return(FoundHunt); } else { //Logging.Log(LogManager.GetCurrentClassLogger(), "Already sent a notification for this hunt recently " + HuntName); return(new FoundHunt()); } } } if (Constants.GameLanguage == "English") { Regex SHuntRegex = HuntsRegEx.SRank; if (SHuntRegex.IsMatch(chatLogEntry.Line)) { HuntZoneLocation CalledHuntLocation = getLocation(chatLogEntry); if (Zones.Contains(CalledHuntLocation.zone) && !PastHunts.HasRecentReportsInSameZone("S", CalledHuntLocation.zone)) { String CalledHuntCallersName = getCallerName(chatLogEntry); String CalledSource = getSource(chatLogEntry); FoundHunt FoundHunt = new FoundHunt("S", CalledHuntLocation, CalledHuntCallersName, CalledSource); return(FoundHunt); } else { //Logging.Log(LogManager.GetCurrentClassLogger(), "Already sent a notification for this hunt recently: S Rank"); return(new FoundHunt()); } } Regex AHuntRegex = HuntsRegEx.ARank; if (AHuntRegex.IsMatch(chatLogEntry.Line)) { HuntZoneLocation CalledHuntLocation = getLocation(chatLogEntry); if (Zones.Contains(CalledHuntLocation.zone) && !PastHunts.HasRecentReportsInSameZone("A", CalledHuntLocation.zone)) { String CalledHuntCallersName = getCallerName(chatLogEntry); String CalledSource = getSource(chatLogEntry); FoundHunt FoundHunt = new FoundHunt("A", CalledHuntLocation, CalledHuntCallersName, CalledSource); return(FoundHunt); } else { //Logging.Log(LogManager.GetCurrentClassLogger(), "Already sent a notification for this hunt recently: A Rank"); return(new FoundHunt()); } } } return(new FoundHunt()); }