Moving common functions to a functions file.
This commit is contained in:
parent
04b2237242
commit
b5b5dc1d10
10
bot.sh
10
bot.sh
@ -1,12 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
msg()
|
[ -f functions.sh ] && source functions.sh
|
||||||
{
|
|
||||||
local msg="PRIVMSG $1"
|
|
||||||
shift
|
|
||||||
echo "$msg :$@" | tee -a "$log"
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -f bot.properties ] && source bot.properties
|
[ -f bot.properties ] && source bot.properties
|
||||||
input=".bot.cfg"
|
input=".bot.cfg"
|
||||||
echo "Starting session: $(date "+[%y:%m:%d %T]")" | tee $log
|
echo "Starting session: $(date "+[%y:%m:%d %T]")" | tee $log
|
||||||
@ -39,7 +33,7 @@ do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "MODE #$channel +o $who" >> $input
|
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
|
# run when a message is seen
|
||||||
*PRIVMSG*)
|
*PRIVMSG*)
|
||||||
|
9
functions.sh
Normal file
9
functions.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
msg()
|
||||||
|
{
|
||||||
|
local msg="PRIVMSG $1"
|
||||||
|
shift
|
||||||
|
echo "$msg $@" | tee -a "$log"
|
||||||
|
}
|
||||||
|
|
@ -1 +1,2 @@
|
|||||||
echo "PRIVMSG $2 :$1: pong"
|
[ -f functions.sh ] && source functions.sh
|
||||||
|
msg $2 "$1: pong"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user