diff --git a/.gitignore b/.gitignore index 296c367..efe9440 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ log.txt -.bot.cfg +.botinput diff --git a/bot.sh b/bot.sh index 0d76205..7ee601d 100755 --- a/bot.sh +++ b/bot.sh @@ -2,7 +2,17 @@ [ -f functions.sh ] && source functions.sh [ -f bot.properties ] && source bot.properties -input=".bot.cfg" +input=".botinput" + +close_bot() +{ +echo -en "QUIT :$quitMessage\r\n" >> "$input" +rm "$input" +sleep 10 +} + +trap close_bot EXIT $? + echo "Starting session: $(date "+[%y:%m:%d %T]")" | tee $log echo "NICK $nick" > $input echo "USER $user" >> $input diff --git a/functions.sh b/functions.sh index a697a06..fd87028 100644 --- a/functions.sh +++ b/functions.sh @@ -1,35 +1,26 @@ #!/bin/bash if [ -z "$input" ]; then -input=".bot.cfg" +input=".botinput" fi msg() { - local msg="PRIVMSG $1" + local msg="PRIVMSG $1 :" shift -echo "$msg $@" | tee -a "$input" +echo -en "${msg}$@\r\n" | tee -a "$input" } reply() { shift local msg="PRIVMSG $1 :" -echo "$msg $@" | tee -a "$input" +echo -en "${msg}$@\r\n" | tee -a "$input" } act() { local msg="PRIVMSG $1 :\x01ACTION" shift -echo -e "$msg $@\x01" | tee -a "$input" +echo -en "$msg $@\x01\r\n" | tee -a "$input" } - -close_bot() -{ -echo "QUIT :$quitMessage" >> "$input" -echo "exiting..." -sleep 10 -} - -trap close_bot EXIT $? diff --git a/modules/coin/coin.sh b/modules/coin/coin.sh new file mode 100755 index 0000000..e56982c --- /dev/null +++ b/modules/coin/coin.sh @@ -0,0 +1,35 @@ +[ -f functions.sh ] && source functions.sh + +case "${3^^}" in +D|DI|DIM|DIME) +coin="dime" +;; +D|DO|DOL|DOLL|DOLLA|DOLLAR) +coin="silver dollar" +;; +H|HA|HAL|HALF|HALF-|HALF-D|HALF-DO|HALF-DOL|HALF-DOLL|HALF-DOLLA|HALF-DOLLAR) +coin="fifty-cent piece" +;; +N|NI|NICNICK|NICKE|NICKEL) +coin="nickel" +;; +P|PE|PEN|PENN|PENNY) +coin="penny" +;; +Q|QU|QUA|QUAR|QUART|QUARTER) +coin="quarter" +;; +*) +coin="$(shuf -n1 -e dime "fifty-cent piece" nickel penny "silver dollar" quarter)" +esac +catch="$(shuf -n1 -e true false)" +flip="$(shuf -n1 -e HEADS TAILS)" + +message="pulls a $coin out, flips it high into the air," +if [ "$catch" = "true" ]; then +message="$message and deftly catches it," +else +message="$message and tries to grab it on the way back down but misses. After lots of cussin', tobaccer juce spittin' and searching, the $coin is found," +fi +message="$message revealing $flip!" +act "$2" "$message" diff --git a/modules/do/do.sh b/modules/do/do.sh new file mode 100755 index 0000000..df4a67c --- /dev/null +++ b/modules/do/do.sh @@ -0,0 +1,6 @@ +[ -f functions.sh ] && source functions.sh + +shift +chan="$1" +shift +act "$chan" "$@" diff --git a/modules/say/say.sh b/modules/say/say.sh new file mode 100755 index 0000000..557ae2f --- /dev/null +++ b/modules/say/say.sh @@ -0,0 +1,6 @@ +[ -f functions.sh ] && source functions.sh + +shift +chan="$1" +shift +msg "$chan" "$@"