Fix parsing for real this time.
This commit is contained in:
@@ -15,6 +15,12 @@ name="$1"
|
||||
channelName="$2"
|
||||
shift 2
|
||||
|
||||
# Parse arguments into array to handle subcommands properly
|
||||
# When bot.sh calls this with "$will", it arrives as a single quoted argument
|
||||
# e.g., "set Ferguson North Carolina" comes as one $1, not multiple args
|
||||
# shellcheck disable=SC2206
|
||||
request=($*)
|
||||
|
||||
# Database file for user locations and cached geocoding
|
||||
weatherDb="data/weather.db"
|
||||
weatherDbLock="${weatherDb}.lock"
|
||||
@@ -453,18 +459,20 @@ format_forecast() {
|
||||
}
|
||||
|
||||
# Main command logic
|
||||
subcommand="${1:-}"
|
||||
# Check if first element is a subcommand
|
||||
subcommand="${request[0]:-}"
|
||||
|
||||
case "$subcommand" in
|
||||
set)
|
||||
# Set user's location
|
||||
shift
|
||||
if [[ $# -eq 0 ]]; then
|
||||
# Remove 'set' from the array and get the rest as location
|
||||
if [[ ${#request[@]} -lt 2 ]]; then
|
||||
msg "$channelName" "$name: Usage: weather set <location>"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
location="$*"
|
||||
# Get everything after 'set' as the location
|
||||
location="${request[*]:1}"
|
||||
|
||||
# Validate location length
|
||||
if [[ ${#location} -gt 100 ]]; then
|
||||
@@ -502,7 +510,7 @@ case "$subcommand" in
|
||||
# Show weather (default action)
|
||||
if [[ -n "$subcommand" ]]; then
|
||||
# Weather for specified location
|
||||
location="$*"
|
||||
location="${request[*]}"
|
||||
|
||||
# Validate location length
|
||||
if [[ ${#location} -gt 100 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user