Fix message format
This commit is contained in:
parent
b29f1d546d
commit
f6cbac70ad
1 changed files with 8 additions and 1 deletions
|
|
@ -54,7 +54,14 @@ func GetInfoFromMsg(msg string) (userId int64, username, joinReason, declinedBy,
|
||||||
index := LastIndexRuneInRunes([]rune(lines[0]), '[')
|
index := LastIndexRuneInRunes([]rune(lines[0]), '[')
|
||||||
userID, _ := strconv.Atoi(string([]rune(lines[0])[index+1 : len([]rune(lines[0]))-1]))
|
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 {
|
func LastIndexRuneInRunes(runes []rune, r rune) int {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue