Moving common functions to a functions file.

This commit is contained in:
Storm Dragon 2016-09-03 00:14:12 -04:00
parent 04b2237242
commit b5b5dc1d10
3 changed files with 13 additions and 9 deletions

10
bot.sh
View File

@ -1,12 +1,6 @@
#!/bin/bash
msg()
{
local msg="PRIVMSG $1"
shift
echo "$msg :$@" | tee -a "$log"
}
[ -f functions.sh ] && source functions.sh
[ -f bot.properties ] && source bot.properties
input=".bot.cfg"
echo "Starting session: $(date "+[%y:%m:%d %T]")" | tee $log
@ -39,7 +33,7 @@ do
continue
fi
echo "MODE #$channel +o $who" >> $input
[ -e greeting.txt ] && msg $chan $who: $(shuf -n1 greeting.txt)
[ -e greeting.txt ] && msg "$chan" "$who: $(shuf -n1 greeting.txt)"
;;
# run when a message is seen
*PRIVMSG*)

9
functions.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
msg()
{
local msg="PRIVMSG $1"
shift
echo "$msg $@" | tee -a "$log"
}

View File

@ -1 +1,2 @@
echo "PRIVMSG $2 :$1: pong"
[ -f functions.sh ] && source functions.sh
msg $2 "$1: pong"