Skip to content

Commit 49bc24f

Browse files
committed
fix: 모니터링 모드 이벤트 파싱 수정 (v2.10.2)
- 블록 분리를 빈 줄 → 타임스탬프(HH:MM) 기준으로 변경 - 배틀 중계/전투/결과가 하나의 블록으로 묶여 정상 파싱 - 승자 이름 '님' 접미사 제거로 VS 패턴과 매칭 수정
1 parent f9129ba commit 49bc24f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

cmd/sword-macro/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func init() {
1919
runtime.LockOSThread()
2020
}
2121

22-
const VERSION = "2.10.1"
22+
const VERSION = "2.10.2"
2323

2424
func main() {
2525
// Windows 콘솔 ANSI 지원 활성화 및 UTF-8 설정

internal/game/parser.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,29 +1111,34 @@ func IsGameBotMessage(text string) bool {
11111111
}
11121112

11131113
// ParseMonitorEvents 텍스트에서 모니터링 이벤트 파싱
1114+
// chatTimestampPattern 채팅 타임스탬프 패턴: "HH:MM 이름" 형식
1115+
var chatTimestampPattern = regexp.MustCompile(`^\d{2}:\d{2}\s+\S+`)
1116+
11141117
func ParseMonitorEvents(text string) []MonitorEvent {
11151118
var events []MonitorEvent
11161119

11171120
lines := strings.Split(text, "\n")
11181121

1119-
// 블록 단위로 분석 (여러 줄이 하나의 이벤트)
1120-
// 빈 줄 또는 구분자로 블록 분리
1122+
// 타임스탬프("HH:MM 이름") 기준으로 블록 분리
1123+
// 타임스탬프 없는 줄(빈 줄, [⚔️전투], [🏆결과] 등)은 이전 메시지의 연속
11211124
var currentBlock []string
11221125

11231126
for _, line := range lines {
1124-
line = strings.TrimSpace(line)
1125-
if line == "" || strings.HasPrefix(line, "━") || strings.HasPrefix(line, "─") {
1126-
// 블록 종료 - 분석
1127+
trimmed := strings.TrimSpace(line)
1128+
if chatTimestampPattern.MatchString(trimmed) {
1129+
// 새 타임스탬프 → 이전 블록 마감
11271130
if len(currentBlock) > 0 {
11281131
blockText := strings.Join(currentBlock, "\n")
11291132
if evt := parseMonitorBlock(blockText); evt != nil {
11301133
events = append(events, *evt)
11311134
}
1132-
currentBlock = nil
11331135
}
1134-
continue
1136+
currentBlock = []string{trimmed}
1137+
} else if trimmed != "" {
1138+
// 타임스탬프 없는 줄 → 이전 블록에 병합
1139+
currentBlock = append(currentBlock, trimmed)
11351140
}
1136-
currentBlock = append(currentBlock, line)
1141+
// 빈 줄은 무시 (블록 분리 안 함)
11371142
}
11381143

11391144
// 마지막 블록 처리
@@ -1227,7 +1232,7 @@ func parseMonitorBlock(text string) *MonitorEvent {
12271232
if matches := monitorBattleWinnerPattern.FindStringSubmatch(text); len(matches) > 1 {
12281233
for i := 1; i < len(matches); i++ {
12291234
if matches[i] != "" {
1230-
evt.Winner = matches[i]
1235+
evt.Winner = strings.TrimSuffix(matches[i], "님")
12311236
winnerFound = true
12321237
break
12331238
}

0 commit comments

Comments
 (0)