From 8e3887d96cdaa9a101face516f4753da87dac5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Sun, 12 Jan 2025 03:57:45 +0500 Subject: [PATCH] Add "w" and "l" commands. --- dobroho_vechora.bash | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/dobroho_vechora.bash b/dobroho_vechora.bash index 89d6f01..5491c2c 100755 --- a/dobroho_vechora.bash +++ b/dobroho_vechora.bash @@ -66,6 +66,14 @@ case "${mode}" in exit esac +print_messages() { + open_socket + echo -n 2 >&3 + head -c "${1}" <&3 | sed -e 's/\x1B/ESC/g' + close_socket +} + +length=0 while :; do read cmd case "${cmd}" in @@ -86,16 +94,25 @@ while :; do read a send_message 0"${nick}${a}" ;; + l) + echo "${length}" + ;; + w) + oldlength="${length}" + while :; do + length="$(get_message 1)" + if [ "${oldlength}" -lt "${length}" ]; then + break + fi + echo -n . + sleep 1 + done + echo + print_messages "${length}" + ;; p) length="$(get_message 1)" - if [ -z "${length}" ]; then - echo !; - else - open_socket - echo -n 2 >&3 - head -c "${length}" <&3 | sed -e 's/\x1B/ESC/g' - close_socket - fi + print_messages "${length}" ;; q) exit