Added parting stuff.
This commit is contained in:
parent
7daab60d2a
commit
a5706b025b
24
bot.sh
24
bot.sh
@ -35,14 +35,29 @@ do
|
||||
echo "MODE #$channel +o $who" >> $input
|
||||
./triggers/greet/greet.sh $who $chan
|
||||
;;
|
||||
# run when someone leaves
|
||||
*PART #*)
|
||||
who=$(echo "$res" | perl -pe "s/:(.*)\!.*@.*/\1/")
|
||||
chan="$(echo "$res" | cut -d '#' -f2)"
|
||||
chan="#$chan"
|
||||
if [ "$who" = "$nick" ]; then
|
||||
continue
|
||||
fi
|
||||
echo "MODE #$channel +o $who" >> $input
|
||||
./triggers/greet/bye.sh $who $chan
|
||||
;;
|
||||
# run when a message is seen
|
||||
*PRIVMSG*)
|
||||
echo "$res"
|
||||
who=$(echo "$res" | perl -pe "s/:(.*)\!.*@.*/\1/")
|
||||
from=$(echo "$res" | perl -pe "s/.*PRIVMSG (.*[#]?([a-zA-Z]|\-)*) :.*/\1/")
|
||||
# This looks to be the spot where triggers should be called
|
||||
# Call link trigger if msg contains a link:
|
||||
if [[ "$res" =~ .*http://|https://|www\..* ]]; then
|
||||
msg "$from" "This contains a url. Unfortunately my master is being lazy and hasn't made a url parser, so I can't tell you where it goes."
|
||||
fi
|
||||
# "#" would mean it's a channel
|
||||
if [ "$(echo "$from" | grep '#')" ]
|
||||
then
|
||||
if [ "$(echo "$from" | grep '#')" ]; then
|
||||
test "$(echo "$res" | grep ":$nick:")" || continue
|
||||
will=$(echo "$res" | perl -pe "s/.*:$nick:(.*)/\1/")
|
||||
else
|
||||
@ -51,14 +66,15 @@ do
|
||||
fi
|
||||
will=$(echo "$will" | perl -pe "s/^ //")
|
||||
com=$(echo "$will" | cut -d " " -f1)
|
||||
if [ -z "$(ls modules/ | grep -i -- "$com")" ] || [ -z "$com" ]
|
||||
then
|
||||
if [ -z "$(ls modules/ | grep -i -- "$com")" ] || [ -z "$com" ]; then
|
||||
./modules/help/help.sh $who $from
|
||||
continue
|
||||
fi
|
||||
./modules/$com/$com.sh $who $from $(echo "$will" | cut -d " " -f2-99)
|
||||
;;
|
||||
*)
|
||||
chan="$(echo "$res" | cut -d '#' -f2)"
|
||||
chan="#$chan"
|
||||
echo "$res"
|
||||
;;
|
||||
esac
|
||||
|
@ -11,3 +11,10 @@ shift
|
||||
echo "$msg $@" | tee -a "$input"
|
||||
}
|
||||
|
||||
act()
|
||||
{
|
||||
local msg="PRIVMSG $1 :\x01ACTION"
|
||||
shift
|
||||
echo -e "$msg $@\x01" | tee -a "$input"
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ shift
|
||||
#get the lyric text into a variable
|
||||
trackName="$@"
|
||||
curl="$(command -v curl)"
|
||||
trackName="$(echo "$trackName" | sed -e "s/ /_/g" -e 's/([[:print:]]*)//g' -e "s/['\/\.]//g" -e 's/&/and/g')"
|
||||
trackName="$(echo "$trackName" | sed -e "s/ /_/g" -e 's/([[:print:]]*)//g' -e "s/['\/\.]//g" -e 's/&/and/g' -e 's/ö/o/g')"
|
||||
artist="$(echo "${trackName,,}" | cut -d "-" -f 1 | sed -e 's/_$//' -e 's/^the_\(.*\)/\1_the/')"
|
||||
song="$(echo "${trackName,,}" | cut -d "-" -f 2 | sed 's/^_//')"
|
||||
lyricsUrl="http://www.lyricsmania.com/${song}_lyrics_${artist}.html"
|
||||
@ -36,7 +36,7 @@ if [ ${#lyricText} -gt 412 ] ; then
|
||||
fi
|
||||
#Display the lyric text
|
||||
if [ ${#lyricText} -gt 15 ] ; then
|
||||
msg "$chan" "${lyricText}"
|
||||
act "$chan" "sings, '${lyricText}'"
|
||||
else
|
||||
msg "$chan" "Sorry $userNick: I couldn't find any lyrics for $@"
|
||||
fi
|
||||
|
13
triggers/bye/bye.sh
Executable file
13
triggers/bye/bye.sh
Executable file
@ -0,0 +1,13 @@
|
||||
[ -f functions.sh ] && source functions.sh
|
||||
# All names to match are completely lowercase.
|
||||
case "${1,,}" in
|
||||
storm_dragon)
|
||||
msg "$2" "NOOOOOOOOOO!!! $1: come back!!!"
|
||||
;;
|
||||
*)
|
||||
bye=(
|
||||
"Bye $1."
|
||||
"Alas $1, you will be missed."
|
||||
)
|
||||
msg "$2" "$1: ${bye[$(($RANDOM % ${#bye[@]}))]}"
|
||||
esac
|
@ -6,10 +6,10 @@ msg "$2" "my lord, $1: how may I serve you?"
|
||||
;;
|
||||
*)
|
||||
greeting=(
|
||||
Greetings
|
||||
Howdy
|
||||
Greetings
|
||||
"Howdy, welcome to $2!"
|
||||
"Wazzup Moe Fugger!"
|
||||
Welcome
|
||||
"Welcome to $2!"
|
||||
)
|
||||
msg "$2" "$1: ${greeting[$(($RANDOM % ${#greeting[@]}))]}"
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user