From 0d8a00d9f407e8572b6e1f9439284f516fdbab87 Mon Sep 17 00:00:00 2001 From: styx Date: Sat, 30 Mar 2019 16:12:08 +0100 Subject: [PATCH] Added support for whispers from poemap.live --- .../mercury/platform/shared/MessageParser.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java b/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java index 88c25d93..171cb3b0 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java +++ b/app-core/src/main/java/com/mercury/platform/shared/MessageParser.java @@ -17,16 +17,19 @@ public class MessageParser { private final static String poeAppPattern = "^(.*\\s)?(.+): (\\s*?wtb\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.+?)\\s+?\\(stash\\s+?\"(.*?)\";\\s+?left\\s+?(\\d+?),\\s+?top\\s+(\\d+?)\\)\\s*?(.*))$"; private final static String poeAppBulkCurrenciesPattern = "^(.*\\s)?(.+): (\\s*?wtb\\s+?(.+?)(\\s+?listed for\\s+?([\\d\\.]+?)\\s+?(.+))?\\s+?in\\s+?(.+?)\\s+?\\(stash\\s+?\"(.*?)\";\\s+?left\\s+?(\\d+?),\\s+?top\\s+(\\d+?)\\)\\s*?(.*))$"; private final static String poeCurrencyPattern = "^(.*\\s)?(.+): (.+ to buy your (\\d+(\\.\\d+)?)? (.+) for my (\\d+(\\.\\d+)?)? (.+) in (.*?)\\.\\s*(.*))$"; + private final static String poeMapLiveRegex = "^(.*\\s)?(.+): (I'd like to exchange my (T\\d+:\\s\\([\\s\\S,]+) for your (T\\d+:\\s\\([\\S,\\s]+) in\\s+?(.+?)\\.)"; private Pattern poeAppItemPattern; private Pattern poeTradeStashItemPattern; private Pattern poeTradeItemPattern; private Pattern poeTradeCurrencyPattern; + private Pattern poeMapLivePattern; public MessageParser() { this.poeAppItemPattern = Pattern.compile(poeAppPattern); this.poeTradeStashItemPattern = Pattern.compile(poeTradeStashTabPattern); this.poeTradeItemPattern = Pattern.compile(poeTradePattern); this.poeTradeCurrencyPattern = Pattern.compile(poeCurrencyPattern); + this.poeMapLivePattern = Pattern.compile(poeMapLiveRegex); } public NotificationDescriptor parse(String fullMessage) { @@ -112,6 +115,20 @@ public NotificationDescriptor parse(String fullMessage) { tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); return tradeNotification; } + Matcher poeTradeMapLiveMatcher = poeMapLivePattern.matcher(fullMessage); + if (poeTradeMapLiveMatcher.find()) { + ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor(); + tradeNotification.setWhisperNickname(poeTradeMapLiveMatcher.group(2)); + tradeNotification.setSourceString(poeTradeMapLiveMatcher.group(3)); + tradeNotification.setItemName(poeTradeMapLiveMatcher.group(5)); + tradeNotification.setOffer(poeTradeMapLiveMatcher.group(4)); + tradeNotification.setLeague(poeTradeMapLiveMatcher.group(6)); + tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); + tradeNotification.setCurCount(0d); + tradeNotification.setCurrency(""); + tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE); + return tradeNotification; + } return null; } }