diff options
author | Márcio Silva <coadde at hyperbola dot info> | 2017-06-02 15:48:13 -0300 |
---|---|---|
committer | Márcio Silva <coadde at hyperbola dot info> | 2017-06-02 17:12:07 -0300 |
commit | ae928016bf637b26326ec335b10898c6c2b0e4b9 (patch) | |
tree | 98fa3a0180c9eba01d3b9082373e7a402c3f632e /transport/dev-tcp.sh | |
parent | b4830e97ae51396ccaa9ca2acb469aef80094ae8 (diff) | |
download | hyperbot-ae928016bf637b26326ec335b10898c6c2b0e4b9.tar.lz hyperbot-ae928016bf637b26326ec335b10898c6c2b0e4b9.tar.xz hyperbot-ae928016bf637b26326ec335b10898c6c2b0e4b9.zip |
Import some files from pbot-ng project and branding this project to hyperbot
Diffstat (limited to 'transport/dev-tcp.sh')
-rw-r--r-- | transport/dev-tcp.sh | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/transport/dev-tcp.sh b/transport/dev-tcp.sh index 9282880..49712b2 100644 --- a/transport/dev-tcp.sh +++ b/transport/dev-tcp.sh @@ -80,14 +80,37 @@ transport_alive() { # 0 If Ok # 1 If connection failed transport_read_line() { - read -ru 3 line - # Fail. - if [[ $? -ne 0 ]]; then - return 1 + while true + do + ze_length="$( wc -l '/tmp/un-provoked-message-store' 2> /dev/null )" + + if [[ -r /tmp/un-provoked-message-store ]] && + [[ -w /tmp/un-provoked-message-store ]] && (( ${ze_length%% *} )) + then + read -r line < /tmp/un-provoked-message-store + line=':tlCJ99mfZl!~user@2001:ba8:1f1:f216::5 PRIVMSG #hyperbola :'"${line}" + + # remove the top line of the file + if (( ${ze_length%% *} < 2 )) + then + echo -n > /tmp/un-provoked-message-store + else + tail -n +2 /tmp/un-provoked-message-store | + sponge /tmp/un-provoked-message-store + fi + + break else - time_get_current 'transport_lastvalidtime' + read -t 5 -ru 3 line + the_return_code="${?}" + (( the_return_code == 0 )) && break + (( the_return_code > 128 )) && continue + [[ "${the_return_code}" -ne 0 ]] && return fi - line=${line//$'\r'/} + done + + time_get_current 'transport_lastvalidtime' + line=${line//$'\r'/} } # Send a line |