blob: 7b3b388896617e277f7b534e8e204f1d41b9e14b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package messages
import (
"fmt"
"regexp"
"strconv"
"strings"
"github.com/pektezol/bitreader"
"github.com/pektezol/demoparser/pkg/verification"
)
type SvcPrint struct {
Message string
}
func ParseSvcPrint(reader *bitreader.Reader) SvcPrint {
svcPrint := SvcPrint{
Message: reader.TryReadString(),
}
// common psycopath behaviour
print := fmt.Sprintf("\t\t%s\n", strings.Replace(strings.ReplaceAll(strings.ReplaceAll(svcPrint.Message, "\n", "\n\t\t"), "\n\t\t\n\t\t", ""), "\n\t\t", "", 1))
// Define a regular expression pattern to match the "Server Number" line and capture the integer value.
pattern := `Server Number: (\d+)`
// Compile the regular expression pattern.
re := regexp.MustCompile(pattern)
// Find the match in the text.
match := re.FindStringSubmatch(print)
if len(match) >= 1 {
serverNumber := match[1]
n, _ := strconv.Atoi(serverNumber)
verification.ServerNumbers = append(verification.ServerNumbers, n)
}
return svcPrint
}
|