Skip to content

Commit

Permalink
- added whisper parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyve747 committed Jun 13, 2020
1 parent 014edf4 commit 160446b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Asset, AssetService } from '@app/assets';
import { TradeBulkMessage, TradeItemMessage, TradeMapMessage, TradeParserBase, TradeParserType, TradePlayerJoinedArea, TradeWhisperDirection } from './trade-chat';
import { TradeBulkMessage, TradeItemMessage, TradeMapMessage, TradeParserBase, TradeParserType, TradePlayerJoinedArea, TradeWhisperDirection, TradeMessage } from './trade-chat';

interface TradeRegexs {
JoinedArea: {
Expand Down Expand Up @@ -38,6 +38,7 @@ export class TradeChatParserService {
if (regexResult) {
const direction = regexResult.groups.from ? TradeWhisperDirection.Incoming : TradeWhisperDirection.Outgoing;
const player = regexResult.groups.player;
const message = regexResult.groups.message;
regexResult = null;

let regexArray = Object.values(this.regexs.TradeItemPrice);
Expand Down Expand Up @@ -70,6 +71,10 @@ export class TradeChatParserService {
if (regexResult) {
return this.mapMapMessage(player, direction, regexResult);
}
else
{
return this.mapWhisperMessage(player, direction, message);
}
}
} else {
const playerJoinedArea = this.parseJoinedArea(line);
Expand All @@ -81,6 +86,16 @@ export class TradeChatParserService {
return { type: TradeParserType.Ignored };
}

private mapWhisperMessage(player: string, direction: TradeWhisperDirection, message: string): TradeMessage {
return {
type: TradeParserType.Whisper,
name: player,
direction,
timeReceived: new Date(),
message
};
}

private mapMapMessage(player: string, direction: TradeWhisperDirection, result: RegExpExecArray): TradeMapMessage {
const { groups } = result;
return {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/poe/data/trade-regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Korean": ": (?<player>.*?) 님이 지역에 들어왔습니다"
},
"Whisper": {
"Universal": "@((?<from>from|de|von|от кого|จาก)|(?<to>to|à|an|para|кому|ถึง)) (<.*?> )*(?<player>.*?):"
"Universal": "@((?<from>from|de|von|от кого|จาก)|(?<to>to|à|an|para|кому|ถึง)) (<.*?> )*(?<player>.*?):(?<message>.*)"
},
"TradeItemPrice": {
"English": "(((Hi, )?I would like to buy your)|wtb) (?<name>.*) listed for (?<price>\\d*([.|,]\\d*)?) (?<currency>.*) in (?<league>.*) \\(stash( tab)? \"(?<stash>.*)\";( position:)? left (?<left>\\d*), top (?<top>\\d*)\\)(?<message>.*)?",
Expand Down

0 comments on commit 160446b

Please sign in to comment.