Import some files from pbot-ng project and branding this project to hyperbot
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -165,14 +165,36 @@ transport_alive() {
|
||||
# 0 If Ok
|
||||
# 1 If connection failed
|
||||
transport_read_line() {
|
||||
read -ru 4 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}"
|
||||
|
||||
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 4 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
|
||||
|
||||
Reference in New Issue
Block a user