6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-30 18:51:03 +00:00

Refactor message formatting

This commit is contained in:
James Mills 2022-03-18 02:26:34 +10:00
parent 8445183c98
commit 4a8bbccce2

@ -30,6 +30,10 @@ get_user () {
echo "$user"
}
format_message() {
printf "%s\t(%s) %s" "$(date +%FT%TZ)" "$(get_user)" "$1"
}
stream () {
if [ -z "$SALTY_IDENTITY" ]; then
echo "SALTY_IDENTITY not set"
@ -75,7 +79,7 @@ readmsgs () {
sendmsg () {
if [ $# -lt 2 ]; then
printf "sendmsg requires 2 arguments %d provided" "$#"
printf "sendmsg requires 2 arguments %d provided\n" "$#"
printf "Try %s send nick@domain message\n" "$(basename "$0")"
return 1
fi
@ -103,7 +107,7 @@ sendmsg () {
rm "$salty_json"
message="[$(date +%FT%TZ)] <$(get_user)> $message"
message="$(format_message "$message")"
echo "$message" \
| salty -i "$SALTY_IDENTITY" -r "$key" \
@ -112,7 +116,7 @@ sendmsg () {
chatwith() {
if [ $# -lt 1 ]; then
printf "chatwith requires 1 arguments %d provided" "$#"
printf "chatwith requires 1 arguments %d provided\n" "$#"
printf "Try %s chat nick@domain\n" "$(basename "$0")"
return 1
fi