Cleaned up the code a bit, the formatting at least, there's plenty more to do.

This commit is contained in:
Storm Dragon 2020-08-13 20:46:09 -04:00
parent 273e24a63a
commit 5984a2dbb2

8
bot.sh
View File

@ -8,8 +8,7 @@ fi
[ -f bot.cfg ] && source bot.cfg [ -f bot.cfg ] && source bot.cfg
input=".botinput" input=".botinput"
close_bot() close_bot() {
{
echo -en "QUIT :$quitMessage\r\n" >> "$input" echo -en "QUIT :$quitMessage\r\n" >> "$input"
rm "$input" rm "$input"
exit 0 exit 0
@ -22,8 +21,7 @@ echo "NICK $nick" > "$input"
echo "USER $user" >> "$input" echo "USER $user" >> "$input"
echo "JOIN #$channel" >> "$input" echo "JOIN #$channel" >> "$input"
tail -f "$input" | telnet "$server" "$port" | while read result tail -f "$input" | telnet "$server" "$port" | while read -r result ; do
do
# log the session # log the session
echo "$(date "+[$dateFormat]") $result" >> "$log" echo "$(date "+[$dateFormat]") $result" >> "$log"
# do things when you see output # do things when you see output
@ -118,7 +116,7 @@ set -f
fi fi
# "#" would mean it's a channel # "#" would mean it's a channel
if [ "$(echo "$from" | grep '#')" ]; then if [ "$(echo "$from" | grep '#')" ]; then
test "$(echo "$result" | grep ":$nick:")" || continue [[ "$(echo "$result" | grep ":$nick:")" ]] || continue
will="${result#*#*:}" will="${result#*#*:}"
will="${will#*:}" will="${will#*:}"
else else