public static void Add(FoundHunt FoundHunt) { String HuntName = FoundHunt.name; if (!_hunts.ContainsKey(HuntName)) { _hunts.Add(HuntName, FoundHunt); } updateWidget(); }
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 Boolean IsRecent(String HuntName) { if (_hunts.ContainsKey(HuntName)) { FoundHunt HuntData = (FoundHunt)_hunts[HuntName]; if (!HuntData.isExpired()) { return(true); } } return(false); }
public static void CheckSingle(String HuntName) { if (_hunts.ContainsKey(HuntName)) { FoundHunt HuntData = (FoundHunt)_hunts[HuntName]; if (HuntData.isExpired()) { _hunts.Remove(HuntName); updateWidget(); } } }
public static void Check() { foreach (DictionaryEntry hunt in _hunts) { string HuntName = (String)hunt.Key; FoundHunt HuntData = (FoundHunt)hunt.Value; if (HuntData.isExpired()) { _hunts.Remove(HuntName); updateWidget(); break; } } }
public static Boolean HasRecentReportsInSameZone(String Rank, String Zone) { DateTime saveNow = DateTime.Now; foreach (DictionaryEntry hunt in _hunts) { string HuntName = (String)hunt.Key; FoundHunt HuntData = (FoundHunt)hunt.Value; if (HuntData.rank == Rank && HuntData.location.zone == Zone && !HuntData.isExpired()) { return(true); } } return(false); }
public static Boolean CheckRecentReports() { DateTime saveNow = DateTime.Now; foreach (DictionaryEntry hunt in _hunts) { string HuntName = (String)hunt.Key; FoundHunt HuntData = (FoundHunt)_hunts[HuntName]; if (!HuntData.isExpired()) { return(true); } } return(false); }
public static void updateWidget() { List <HuntEntity> _HuntEntity = new List <HuntEntity>(); foreach (DictionaryEntry hunt in _hunts) { FoundHunt HuntData = (FoundHunt)hunt.Value; if (HuntData.canDisplay()) { HuntEntity Hunt = new HuntEntity(HuntData.friendlyname, HuntData.rank, HuntData.location, HuntData.caller, HuntData.time); _HuntEntity.Add(Hunt); } } List <HuntEntity> HuntEntity = _HuntEntity.OrderByDescending(p => p._Time.Ticks).ToList(); HuntWidgetViewModel.Instance.HuntEntity = HuntEntity; }
public static void SendPost(FoundHunt FoundHunt, ChatLogEntry chatLogEntry) { try { String title; String Message = FoundHunt.friendlyname + " Popped at: " + FoundHunt.location.ToString() + "\nCalled out in " + FoundHunt.source + " chat by " + FoundHunt.caller; if (!FoundHunt.isNamed()) { title = FoundHunt.rank + " Rank Popped!"; Message += "\n" + chatLogEntry.Line; } else { title = FoundHunt.rank + " Rank: " + FoundHunt.friendlyname + " Popped!"; } Boolean pushoverSendRankNotification = ((FoundHunt.rank == "S" && Settings.Default.pushoverSendSRankNotifications) || (FoundHunt.rank == "A" && Settings.Default.pushoverSendARankNotifications)); if (Settings.Default.EnablePushoverService && pushoverSendRankNotification) { NotificationPublisher.PublishPushOver(title, Message); } Boolean nmaSendRankNotification = ((FoundHunt.rank == "S" && Settings.Default.notifymyandroidSendSRankNotifications) || (FoundHunt.rank == "A" && Settings.Default.notifymyandroidSendARankNotifications)); if (Settings.Default.EnableNotifyMyAndroidService && nmaSendRankNotification) { NotificationPublisher.PublishNotifyMyAndroidKey(title, Message); } Boolean growlSendRankNotification = ((FoundHunt.rank == "S" && Settings.Default.growlSendSRankNotifications) || (FoundHunt.rank == "A" && Settings.Default.growlSendARankNotifications)); if (Settings.Default.EnableGrowl && growlSendRankNotification) { GrowlPublisher.growlNotify(title, Message); } } catch (Exception ex) { Logging.Log(LogManager.GetCurrentClassLogger(), "", ex); } }
public static DateTime getHuntDate(String HuntName) { FoundHunt HuntData = (FoundHunt)_hunts[HuntName]; return((DateTime)HuntData.time); }
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()); }