File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 -
2020 name : Set up Go
2121 uses : actions/setup-go@v4
22+ with :
23+ go-version-file : ./go.mod
2224 -
2325 name : Run GoReleaser
2426 uses : goreleaser/goreleaser-action@v5
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ WORKDIR /app/
99ADD . .
1010RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o /palog .
1111
12- FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
12+ FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.19
1313COPY --from=builder /palog /palog
14+ RUN apk add --no-cache icu
1415
1516ENTRYPOINT ["/palog" ]
Original file line number Diff line number Diff line change @@ -12,3 +12,5 @@ Broadcast messages that someone joined/left the game.
1212
1313## Known issues
1414* If the message is split via whitespaces, ` Broadcast ` sends only the first segment
15+ * CKJ characters are corrupted
16+ * https://github.com/miscord-dev/palog/issues/6
Original file line number Diff line number Diff line change 44 "fmt"
55 "log/slog"
66 "os"
7+ "os/exec"
8+ "strings"
79 "time"
810
911 "github.com/miscord-dev/palog/pkg/palrcon"
1820
1921 timeoutRaw = os .Getenv ("TIMEOUT" )
2022 timeout time.Duration
23+
24+ uconvLatin = os .Getenv ("UCONV_LATIN" ) != "false"
2125)
2226
2327func init () {
@@ -45,6 +49,28 @@ func init() {
4549 }
4650}
4751
52+ func escapeString (s string ) string {
53+ s = strings .ReplaceAll (s , " " , "_" )
54+
55+ if ! uconvLatin {
56+ return s
57+ }
58+
59+ var out strings.Builder
60+ cmd := exec .Command ("uconv" , "-x" , "latin" )
61+ cmd .Stdin = strings .NewReader (s )
62+ cmd .Stderr = os .Stderr
63+ cmd .Stdout = & out
64+
65+ err := cmd .Run ()
66+ if err != nil {
67+ slog .Error ("failed to run uconv" , "error" , err )
68+ return s
69+ }
70+
71+ return strings .TrimSpace (out .String ())
72+ }
73+
4874func main () {
4975 palRCON := palrcon .NewPalRCON (rconEndpoint , rconPassword )
5076 palRCON .SetTimeout (timeout )
@@ -66,6 +92,8 @@ func main() {
6692 }
6793
6894 retriedBoarcast := func (message string ) error {
95+ message = escapeString (message )
96+
6997 var err error
7098 for i := 0 ; i < 10 ; i ++ {
7199 err = palRCON .Broadcast (message )
You can’t perform that action at this time.
0 commit comments