A few updates, cleanup updated weather module.
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
[ -f functions.sh ] && source functions.sh
|
||||
|
||||
# Dependencies required by this module
|
||||
dependencies=("curl" "w3m" "grep" "sed" "iconv")
|
||||
|
||||
set -f
|
||||
quote="$(curl -s http://bash.org/?random)"
|
||||
quote="$(curl -s --connect-timeout 5 --max-time 10 http://bash.org/?random)"
|
||||
if [[ -z "$quote" ]]; then
|
||||
msg "$2" "$1: Sorry, couldn't fetch a bash.org quote right now."
|
||||
set +f
|
||||
exit 1
|
||||
fi
|
||||
quote="$(echo "$quote" | grep -m 1 -A 10 '"Permanent link to this quote."')"
|
||||
quote="${quote#*class=\"qt\">}"
|
||||
quote="${quote//</ <}"
|
||||
quote="${quote//>/> }"
|
||||
quote="${quote%%<p class*}"
|
||||
quote="$(echo "$quote" | w3m -dump -T text/html)"
|
||||
msg "$2" "$(echo "$quote" | iconv -f utf-8 -t ascii)"
|
||||
if [[ ${#quote} -lt 5 ]]; then
|
||||
msg "$2" "$1: Sorry, couldn't parse the bash.org quote."
|
||||
else
|
||||
msg "$2" "$(echo "$quote" | iconv -f utf-8 -t ascii)"
|
||||
fi
|
||||
set +f
|
||||
|
||||
Reference in New Issue
Block a user