stormbot/triggers/link/link.sh

14 lines
357 B
Bash
Raw Normal View History

2016-09-04 17:22:05 -04:00
[ -f functions.sh ] && source functions.sh
2016-09-04 19:15:51 -04:00
curl="$(command -v curl)"
2016-09-04 17:22:05 -04:00
for l in $3 ; do
if [[ "$l" =~ http://|https://|www\.*.* ]]; then
2016-09-04 19:15:51 -04:00
pageTitle="$($curl -Ls "${l/#:/}" | grep "<title>" | html2text | tr '[:space:]' ' ')"
2016-09-04 17:22:05 -04:00
shortLink="${l#*://}"
shortLink="${shortLink%%/*}"
if ! [[ "$pageTitle" =~ \ + ]]; then
2016-09-04 17:22:05 -04:00
msg "$2" "$pageTitle at $shortLink"
fi
fi
2016-09-04 17:22:05 -04:00
done