Skip to content

Commit ba5efc5

Browse files
authored
Merge pull request #357 from Rottenbeer/poemap_fix
Added support for whispers from poemap.live
2 parents c81fdc6 + 0d8a00d commit ba5efc5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app-core/src/main/java/com/mercury/platform/shared/MessageParser.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ public class MessageParser {
1717
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*?(.*))$";
1818
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*?(.*))$";
1919
private final static String poeCurrencyPattern = "^(.*\\s)?(.+): (.+ to buy your (\\d+(\\.\\d+)?)? (.+) for my (\\d+(\\.\\d+)?)? (.+) in (.*?)\\.\\s*(.*))$";
20+
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+?(.+?)\\.)";
2021
private Pattern poeAppItemPattern;
2122
private Pattern poeTradeStashItemPattern;
2223
private Pattern poeTradeItemPattern;
2324
private Pattern poeTradeCurrencyPattern;
25+
private Pattern poeMapLivePattern;
2426

2527
public MessageParser() {
2628
this.poeAppItemPattern = Pattern.compile(poeAppPattern);
2729
this.poeTradeStashItemPattern = Pattern.compile(poeTradeStashTabPattern);
2830
this.poeTradeItemPattern = Pattern.compile(poeTradePattern);
2931
this.poeTradeCurrencyPattern = Pattern.compile(poeCurrencyPattern);
32+
this.poeMapLivePattern = Pattern.compile(poeMapLiveRegex);
3033
}
3134

3235
public NotificationDescriptor parse(String fullMessage) {
@@ -112,6 +115,20 @@ public NotificationDescriptor parse(String fullMessage) {
112115
tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE);
113116
return tradeNotification;
114117
}
118+
Matcher poeTradeMapLiveMatcher = poeMapLivePattern.matcher(fullMessage);
119+
if (poeTradeMapLiveMatcher.find()) {
120+
ItemTradeNotificationDescriptor tradeNotification = new ItemTradeNotificationDescriptor();
121+
tradeNotification.setWhisperNickname(poeTradeMapLiveMatcher.group(2));
122+
tradeNotification.setSourceString(poeTradeMapLiveMatcher.group(3));
123+
tradeNotification.setItemName(poeTradeMapLiveMatcher.group(5));
124+
tradeNotification.setOffer(poeTradeMapLiveMatcher.group(4));
125+
tradeNotification.setLeague(poeTradeMapLiveMatcher.group(6));
126+
tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE);
127+
tradeNotification.setCurCount(0d);
128+
tradeNotification.setCurrency("");
129+
tradeNotification.setType(NotificationType.INC_ITEM_MESSAGE);
130+
return tradeNotification;
131+
}
115132
return null;
116133
}
117134
}

0 commit comments

Comments
 (0)