diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index d425d87..371fc2c 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -54,7 +54,14 @@ func GetInfoFromMsg(msg string) (userId int64, username, joinReason, declinedBy, index := LastIndexRuneInRunes([]rune(lines[0]), '[') userID, _ := strconv.Atoi(string([]rune(lines[0])[index+1 : len([]rune(lines[0]))-1])) - return int64(userID), EscapeHTML(username), EscapeHTML(joinReason), declinedBy, declinedAt + // Extract username from "for %s [" part + forIndex := strings.Index(lines[0], "for ") + bracketIndex := strings.Index(lines[0][forIndex:], "[") + if forIndex != -1 && bracketIndex != -1 { + username = strings.TrimSpace(lines[0][forIndex+4 : forIndex+bracketIndex]) + } + + return int64(userID), username, EscapeHTML(joinReason), declinedBy, declinedAt } func LastIndexRuneInRunes(runes []rune, r rune) int {