stormbot/triggers/link/link.sh

18 lines
481 B
Bash
Raw Normal View History

2016-09-04 17:22:05 -04:00
[ -f functions.sh ] && source functions.sh
for l in $3 ; do
if [[ "${l}" =~ http://|https://|www\..* ]]; then
2020-08-09 21:28:25 -04:00
pageTitle="$(curl -s --connect-timeout 5 "$l" | sed -n -e 'H;${x;s!.*<head[^>]*>\(.*\)</head>.*!\1!;T;s!.*<title>\(.*\)</title>.*!\1!p}')"
# Fix up pageTitle a bit.
pageTitle="${pageTitle//&#039;/\'}"
pageTitle="${pageTitle//&#8211;/-}"
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