stormbot/triggers/link/link.sh

13 lines
434 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
2020-08-10 18:39:43 -04:00
text="${l#:}"
if [[ "${text}" =~ http://|https://|www\..* ]]; then
pageTitle="$(curl -L -s --connect-timeout 5 "$text" | sed -n -e 'H;${x;s!.*<head[^>]*>\(.*\)</head>.*!\1!;T;s!.*<title>\(.*\)</title>.*!\1!p}' | pandoc -t plain | tr '[:space:]' ' ')"
2020-08-10 18:49:43 -04:00
pageTitle="$(echo "$pageTitle" | tr -cd '[:print:]')"
2020-08-10 09:35:15 -04:00
if [[ ${#pageTitle} -gt 1 ]]; then
2020-08-10 18:53:13 -04:00
msg "$2" "$pageTitle"
2016-09-04 17:22:05 -04:00
fi
fi
2016-09-04 17:22:05 -04:00
done