coin module.

This commit is contained in:
Storm Dragon 2016-09-05 21:44:04 -04:00
parent af18b6c47a
commit d9b180deb3
6 changed files with 64 additions and 16 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
log.txt
.bot.cfg
.botinput

12
bot.sh
View File

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

View File

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

35
modules/coin/coin.sh Executable file
View File

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

6
modules/do/do.sh Executable file
View File

@ -0,0 +1,6 @@
[ -f functions.sh ] && source functions.sh
shift
chan="$1"
shift
act "$chan" "$@"

6
modules/say/say.sh Executable file
View File

@ -0,0 +1,6 @@
[ -f functions.sh ] && source functions.sh
shift
chan="$1"
shift
msg "$chan" "$@"