Skip to content

Instantly share code, notes, and snippets.

@alexfornuto
Last active February 14, 2024 22:33
Show Gist options
  • Save alexfornuto/7808c4516560e69281794b617ef5ef25 to your computer and use it in GitHub Desktop.
Save alexfornuto/7808c4516560e69281794b617ef5ef25 to your computer and use it in GitHub Desktop.
Broadcast messages to a Palworld server
#!/bin/bash
#
# messageServer: A simple script to split input and format it for broadcast to
# a Palworld server using ARRCON (https://github.com/radj307/ARRCON).
#
# Author: Alex Fornuto 2024 <alex@fornuto.com>
input=$1
# For Debugging
#printf 'You entered: "%s"\n' "$input"
# Breaks up the input to the script into an array of lines no longer than 30
# characters, without breaking up words.
splitinput=()
while IFS= read -r line; do
splitinput+=($(echo "$line" | sed $'s/\(.\\{1,30\\}\) /\\1\\\n/g;s/ /_/g'))
done <<<"$input"
# For Debugging
#printf 'Split for Palworld as "%s"\n' "${splitinput[@]}"
for msg in "${splitinput[@]}"; do
# For Debugging
#echo "$msg"
## For Debugging
#printf 'Value of msg is: "%s"\n' "$msg"
#charcount="$(expr $(echo $msg | wc -m) - $(echo $msg | wc -l) )"
#printf 'Char count: "%s"\n' "$charcount"
#echo "$charcount"
# This line assumes that the ARRCON binary is in the same directory as this
# script, and there's a configuration previously saved as 'local' with the
# `--save-host` flag.
echo Broadcast $msg | ./ARRCON -S local
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment