stormbot/triggers/link/link.sh

14 lines
413 B
Bash
Raw Normal View History

2016-09-04 17:22:05 -04:00
[ -f functions.sh ] && source functions.sh
2017-05-20 08:33:05 -04:00
curl="$(command -v curl) --connect-timeout 5"
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#:}" | sed -n 's/<title>\(.*\)<\/title>/\1/p' | head -1 | 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