Fixed some bugs in the sing module. Probably introduced new ones lol.
This commit is contained in:
parent
66ef3b9680
commit
44bfb39e4c
@ -1,16 +1,25 @@
|
|||||||
[ -f functions.sh ] && source functions.sh
|
[ -f functions.sh ] && source functions.sh
|
||||||
|
|
||||||
userNick="$1"
|
|
||||||
shift
|
shift
|
||||||
chan="$1"
|
chan="$1"
|
||||||
shift
|
shift
|
||||||
#get the lyric text into a variable
|
#get the lyric text into a variable
|
||||||
trackName="${@//:/ - }"
|
trackName="${@//Ã/o}"
|
||||||
trackName="${@//Ö/o}"
|
trackName="${trackName//:/-}"
|
||||||
# Try to work around some common tags that will fail to find lyrics.
|
trackName="$(echo "$trackName" | sed -r -e "s/((\w|\d| |\.|!|\?|')+ - (\w|\d| |\.|!|\?|')+)( +\[| +\(| +- ).*/\1/")"
|
||||||
trackName="${trackName//\//_}"
|
# Random agent string
|
||||||
curl="$(command -v curl)"
|
agent="$(shuf -n 1 -e \
|
||||||
trackName="$(echo "$trackName" | sed -e "s/ /_/g" -e 's/([[:print:]]*)//g' -e "s/['\/\.]//g" -e 's/&/and/g' -e 's/ö/o/g')"
|
"Mozilla/5.0 (Android; Mobile; rv:40.0) Gecko/40.0 Firefox/40.0"\
|
||||||
|
"Mozilla/5.0 (Android; Tablet; rv:40.0) Gecko/40.0 Firefox/40.0"\
|
||||||
|
"Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36")"
|
||||||
|
# Get our curl command
|
||||||
|
unset curl
|
||||||
|
if command -v torify &> /dev/null ; then
|
||||||
|
curl="torify "
|
||||||
|
fi
|
||||||
|
curl="${curl}curl"
|
||||||
|
#Lyricsmania
|
||||||
|
trackName="$(echo "$trackName" | sed -e "s/ /_/g" -e "s/([[:print:]]*)//g" -e "s/['\/\.]//g" -e 's/&/and/g')"
|
||||||
artist="$(echo "${trackName,,}" | cut -d "-" -f 1 | sed -e 's/_$//' -e 's/^the_\(.*\)/\1_the/')"
|
artist="$(echo "${trackName,,}" | cut -d "-" -f 1 | sed -e 's/_$//' -e 's/^the_\(.*\)/\1_the/')"
|
||||||
song="$(echo "${trackName,,}" | cut -d "-" -f 2 | sed 's/^_//')"
|
song="$(echo "${trackName,,}" | cut -d "-" -f 2 | sed 's/^_//')"
|
||||||
lyricsUrl="http://www.lyricsmania.com/${song}_lyrics_${artist}.html"
|
lyricsUrl="http://www.lyricsmania.com/${song}_lyrics_${artist}.html"
|
||||||
@ -37,10 +46,12 @@ if [ ${#lyricText} -gt 412 ] ; then
|
|||||||
lyricText="${lyricText:0:409}... "
|
lyricText="${lyricText:0:409}... "
|
||||||
lyricText="$(echo "$lyricText" | rev | cut -d " " -f 1- | rev)"
|
lyricText="$(echo "$lyricText" | rev | cut -d " " -f 1- | rev)"
|
||||||
fi
|
fi
|
||||||
lyricText="$(echo "$lyricText" | sed -e 's/try {.*//g' -e 's/ +_402_Show//g')"
|
#remove simi-colons
|
||||||
|
lyricText="$(echo "$lyricText" | tr ';' ':' | sed 's/try { _402_Show(): } catch(e) {}//')"
|
||||||
#Display the lyric text
|
#Display the lyric text
|
||||||
if [ ${#lyricText} -gt 15 ] ; then
|
if [ ${#lyricText} -gt 15 ] ; then
|
||||||
act "$chan" "sings, '${lyricText}'"
|
msg "$chan" "${lyricText}"
|
||||||
else
|
exit 0
|
||||||
msg "$chan" "Sorry $userNick: I couldn't find any lyrics for $@"
|
|
||||||
fi
|
fi
|
||||||
|
msg "$chan" "no lyrics found for ${trackName}."
|
||||||
|
exit 0
|
||||||
|
@ -4,6 +4,9 @@ case "${1,,}" in
|
|||||||
storm_dragon)
|
storm_dragon)
|
||||||
msg "$2" "my lord, $1: how may I serve you?"
|
msg "$2" "my lord, $1: how may I serve you?"
|
||||||
;;
|
;;
|
||||||
|
kendell*)
|
||||||
|
msg "$2" "Hey hey $1: what do you say, how many Dudes did you love today?"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
greeting=(
|
greeting=(
|
||||||
Greetings
|
Greetings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user