First pass at link announcing.
This commit is contained in:
parent
4f525e713f
commit
3fcf1c280f
@ -14,4 +14,6 @@ nick="storm_bot"
|
|||||||
port=6667
|
port=6667
|
||||||
server="irc.netwirc.tk"
|
server="irc.netwirc.tk"
|
||||||
# format=username hostname servername :realname
|
# format=username hostname servername :realname
|
||||||
|
# Triggers, symbols, that when starting a message, will cause the bot to search modules.
|
||||||
|
triggers=","
|
||||||
user="$nick ${server%.} $server :$nick"
|
user="$nick ${server%.} $server :$nick"
|
||||||
|
16
bot.sh
16
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,7 @@ 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
|
[ "${greet^^}" = "TRUE" ] && ./triggers/greet/greet.sh $who $chan
|
||||||
;;
|
;;
|
||||||
# run when someone leaves
|
# run when someone leaves
|
||||||
*"PART #"*)
|
*"PART #"*)
|
||||||
@ -44,7 +44,7 @@ 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
|
[ "${leave^^}" = "TRUE" ] && ./triggers/bye/bye.sh $who $chan
|
||||||
;;
|
;;
|
||||||
# run when a message is seen
|
# run when a message is seen
|
||||||
*PRIVMSG*)
|
*PRIVMSG*)
|
||||||
@ -54,7 +54,15 @@ do
|
|||||||
# This looks to be the spot where triggers should be called
|
# This looks to be the spot where triggers should be called
|
||||||
# Call link trigger if msg contains a link:
|
# Call link trigger if msg contains a link:
|
||||||
if [[ "$res" =~ .*http://|https://|www\..* ]]; then
|
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."
|
./triggers/link/link.sh "$who" "$from" "$res"
|
||||||
|
# Although this calls modules, it triggers on text other than the bot's nick
|
||||||
|
elif [[ "$res" =~ .*$from\ :$who:$triggers.* ]]; then
|
||||||
|
com"${res#*$from :$who:$triggers}"
|
||||||
|
if [ -z "$(ls modules/ | grep -i -- "${com%* }")" ] || [ -z "$com" ]; then
|
||||||
|
./modules/help/help.sh $who $from
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
./modules/${com% *}/${com% *}.sh $who $from "${com#* }"
|
||||||
fi
|
fi
|
||||||
# "#" would mean it's a channel
|
# "#" would mean it's a channel
|
||||||
if [ "$(echo "$from" | grep '#')" ]; then
|
if [ "$(echo "$from" | grep '#')" ]; then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ -f functions.sh ] && source functions.sh
|
[ -f functions.sh ] && source functions.sh
|
||||||
output="$1: The modules I have are:"
|
output="$1: The modules I have are:"
|
||||||
output="$output $(find modules/ -type d | tr '[:space:]' ' ' | sed -e 's#modules/##g')"
|
output="$output $(find modules/ -type d | sort -d | tr '[:space:]' ' ' | sed -e 's#modules/##g')"
|
||||||
msg "$2" "$output"
|
msg "$2" "$output"
|
||||||
|
10
triggers/link/link.sh
Executable file
10
triggers/link/link.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
[ -f functions.sh ] && source functions.sh
|
||||||
|
|
||||||
|
for l in $3 ; do
|
||||||
|
if [[ "$l" =~ http://|https://|www\.* ]]; then
|
||||||
|
pageTitle="$(curl -s "$l" | grep "<title>" | sed 's#\(</\|</\)title>##g')"
|
||||||
|
shortLink="${l#*://}"
|
||||||
|
shortLink="${shortLink%%/*}"
|
||||||
|
msg "$2" "$pageTitle at $shortLink"
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user