#!/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!.*]*>\(.*\).*!\1!;T;s!.*\(.*\).*!\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