stormbot/triggers/link/link.sh

14 lines
359 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
2016-09-08 12:16:59 -04:00
if [[ "${l#:}" =~ http://|https://|www\.*\.* ]]; then
pageTitle="$($curl -Ls "${l#:}" | grep "<title>" | html2text | tr -s '[:space:]' ' ')"
2016-09-04 17:22:05 -04:00
shortLink="${l#*://}"
shortLink="${shortLink%%/*}"
2016-09-08 12:16:59 -04:00
if [ ${#pageTitle} -gt 1 ]; 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