Import some files from pbot-ng project and branding this project to hyperbot

This commit is contained in:
Márcio Silva
2017-06-02 15:48:13 -03:00
parent b4830e97ae
commit ae928016bf
44 changed files with 1225 additions and 12 deletions

View File

@@ -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

View File

@@ -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