commands work even with extra spaces at the beginning.
This commit is contained in:
parent
a190c08bdf
commit
09061a7e76
17
bot.sh
17
bot.sh
@ -25,7 +25,7 @@ do
|
|||||||
echo "JOIN #$channel" >> $input
|
echo "JOIN #$channel" >> $input
|
||||||
;;
|
;;
|
||||||
# run when someone joins
|
# run when someone joins
|
||||||
*"JOIN #"*)
|
*"JOIN :#"*)
|
||||||
who=$(echo "$res" | perl -pe "s/:(.*)\!.*@.*/\1/")
|
who=$(echo "$res" | perl -pe "s/:(.*)\!.*@.*/\1/")
|
||||||
chan="$(echo "$res" | cut -d '#' -f2)"
|
chan="$(echo "$res" | cut -d '#' -f2)"
|
||||||
chan="#$chan"
|
chan="#$chan"
|
||||||
@ -33,7 +33,9 @@ do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "MODE #$channel +o $who" >> $input
|
echo "MODE #$channel +o $who" >> $input
|
||||||
[ "${greet^^}" = "TRUE" ] && ./triggers/greet/greet.sh $who $chan
|
if [ "${greet^^}" = "TRUE" ]; then
|
||||||
|
./triggers/greet/greet.sh $who $chan
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
# run when someone leaves
|
# run when someone leaves
|
||||||
*"PART #"*)
|
*"PART #"*)
|
||||||
@ -44,7 +46,9 @@ do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "MODE #$channel +o $who" >> $input
|
echo "MODE #$channel +o $who" >> $input
|
||||||
[ "${leave^^}" = "TRUE" ] && ./triggers/bye/bye.sh $who $chan
|
if [ "${leave^^}" = "TRUE" ]; then
|
||||||
|
./triggers/bye/bye.sh $who $chan
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
# run when a message is seen
|
# run when a message is seen
|
||||||
*PRIVMSG*)
|
*PRIVMSG*)
|
||||||
@ -56,8 +60,9 @@ do
|
|||||||
if [[ "$res" =~ .*http://|https://|www\..* ]]; then
|
if [[ "$res" =~ .*http://|https://|www\..* ]]; then
|
||||||
./triggers/link/link.sh "$who" "$from" "$res"
|
./triggers/link/link.sh "$who" "$from" "$res"
|
||||||
# Although this calls modules, it triggers on text other than the bot's nick
|
# Although this calls modules, it triggers on text other than the bot's nick
|
||||||
elif [[ "$res" =~ .*$from\ :$who:$triggers.* ]]; then
|
elif [[ "$res" =~ *PRIVMSG\ \#${from#*#}\ :$triggers* ]]; then
|
||||||
com"${res#*$from :$who:$triggers}"
|
com"${res#*:$triggers}"
|
||||||
|
com"${com//# /}"
|
||||||
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
|
./modules/help/help.sh $who $from
|
||||||
continue
|
continue
|
||||||
@ -72,7 +77,7 @@ do
|
|||||||
will=$(echo "$res" | perl -pe "s/.*$nick :(.*)/\1/")
|
will=$(echo "$res" | perl -pe "s/.*$nick :(.*)/\1/")
|
||||||
from=$who
|
from=$who
|
||||||
fi
|
fi
|
||||||
will=$(echo "$will" | perl -pe "s/^ //")
|
will=$(echo "$will" | perl -pe "s/^ +//")
|
||||||
com=$(echo "$will" | cut -d " " -f1)
|
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
|
./modules/help/help.sh $who $from
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
curl="$(command -v curl)"
|
curl="$(command -v curl)"
|
||||||
for l in $3 ; do
|
for l in $3 ; do
|
||||||
if [[ "$l" =~ http://|https://|www\.* ]]; then
|
if [[ "$l" =~ http://|https://|www\.*.* ]]; then
|
||||||
pageTitle="$($curl -Ls "${l/#:/}" | grep "<title>" | html2text | tr '[:space:]' ' ')"
|
pageTitle="$($curl -Ls "${l/#:/}" | grep "<title>" | html2text | tr '[:space:]' ' ')"
|
||||||
shortLink="${l#*://}"
|
shortLink="${l#*://}"
|
||||||
shortLink="${shortLink%%/*}"
|
shortLink="${shortLink%%/*}"
|
||||||
|
if ! [[ "$pageTitle" =~ \ + ]]; then
|
||||||
msg "$2" "$pageTitle at $shortLink"
|
msg "$2" "$pageTitle at $shortLink"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user