22 lines
697 B
Bash
Executable File
22 lines
697 B
Bash
Executable File
#!/usr/bin/env bash
|
|
[ -f functions.sh ] && source functions.sh
|
|
|
|
# Dependencies required by this trigger
|
|
dependencies=("curl" "w3m" "sed")
|
|
|
|
# Silently skip if dependencies are missing (triggers shouldn't error in channel)
|
|
if ! check_dependencies "${dependencies[@]}" &> /dev/null; then
|
|
exit 0
|
|
fi
|
|
|
|
for l in $3 ; do
|
|
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}' | w3m -dump -T text/html | tr '[:space:]' ' ')"
|
|
pageTitle="$(echo "$pageTitle" | tr -cd '[:print:]')"
|
|
if [[ ${#pageTitle} -gt 1 ]]; then
|
|
msg "$2" "$pageTitle"
|
|
fi
|
|
fi
|
|
done
|