# HG changeset patch # User Matti Hamalainen # Date 1611735899 -7200 # Node ID dae8f6ad12c24de3773acb3c6458db9f0d378811 # Parent 03d3ec856e4d532a36423f61fe6cf2f9769347e9 weather: Fix weather_cmd return values. diff -r 03d3ec856e4d -r dae8f6ad12c2 weather.tcl --- a/weather.tcl Wed Jan 27 10:24:44 2021 +0200 +++ b/weather.tcl Wed Jan 27 10:24:59 2021 +0200 @@ -305,14 +305,14 @@ foreach ukey $weather_messages(help_full) { weather_msg $upublic $unick $uchan $ukey } - return 0 + return 1 } if {$rcmd == "asemat" || $rcmd == "stations"} { # List stations/locations matching the given pattern if {[llength $rarglist] < 2} { weather_msg $upublic $unick $uchan "help_stations" - return 0 + return 1 } set rmatch [join [lrange $rarglist 1 end] " "] @@ -335,19 +335,19 @@ } weather_msg $upublic $unick $uchan "stations_list" [list $res] - return 0 + return 1 } elseif {$rcmd == "lahin" || $rcmd == "lähin" || $rcmd == "closest" || $rcmd == "nearest"} { # List stations nearest to given coordinates set qargs [join [lrange $rarglist 1 end] ""] if {![regexp {@?(\d+|\d+\.\d+|\.\d+)\s*,\s*(\d+|\d+\.\d+|\.\d+)} $qargs -> d_lat d_lng]} { weather_msg $upublic $unick $uchan "help_nearest" - return 0 + return 1 } # Check argument types if {![string is double -strict $d_lat] || ![string is double -strict $d_lng]} { weather_msg $upublic $unick $uchan "nearest_invalid" - return 0 + return 1 } # Calculate distances between given coordinates for each location @@ -373,14 +373,14 @@ # Print out the result set res [join $uresult " ; "] weather_msg $upublic $unick $uchan "nearest_stations" [list $d_lat $d_lng $res] - return 0 + return 1 } elseif {$rcmd == "vakio" || $rcmd == "default" || $rcmd == "vakiot" || $rcmd == "defaults"} { # List or set the default weather station name patterns for this user # Access check if {![utl_valid_user $uhand]} { weather_msg $upublic $unick $uchan "user_not_known" - return 0 + return 1 } if {[llength $rarglist] == 1} { @@ -403,19 +403,19 @@ weather_msg $upublic $unick $uchan "help_def_set" } } - return 0 + return 1 } elseif {$rcmd == "alias"} { # Alias a string to another, only certain users have access (+n flag) if {![utl_valid_user $uhand] || ![matchattr $uhand n]} { weather_msg $upublic $unick $uchan "no_access" - return 0 + return 1 } set qlist [::textutil::split::splitx [join [lrange $rarglist 1 end] " "] {\s*=\s*}] set nlist [lsearch -all -inline -not -exact $qlist ""] if {[llength $nlist] < 2} { weather_msg $upublic $unick $uchan "help_alias" - return 0 + return 1 } set ualias [lindex $nlist 0] @@ -430,31 +430,31 @@ set weather_aliases($ualias) $uname weather_save_aliases - return 0 + return 1 } elseif {$rcmd == "unalias"} { # Remove one alias, only certain users have access (+n flag) if {![utl_valid_user $uhand] || ![matchattr $uhand n]} { weather_msg $upublic $unick $uchan "no_access" - return 0 + return 1 } if {[llength $rarglist] < 2} { weather_msg $upublic $unick $uchan "help_unalias" - return 0 + return 1 } set ualias [lindex $rarglist 1] if {![info exists weather_aliases($ualias)]} { weather_msg $upublic $unick $uchan "alias_not_exist" [list $ualias] - return 0 + return 1 } weather_msg $upublic $unick $uchan "alias_unset" [list $ualias $weather_aliases($ualias)] unset weather_aliases($ualias) weather_save_aliases - return 0 + return 1 } elseif {$rcmd == "list"} { # List all currently defined aliases set ulist {} @@ -466,7 +466,7 @@ } weather_msg $upublic $unick $uchan "alias_list" [list [join $ulist $ulistsep]] - return 0 + return 1 } # Get args or default location(s) @@ -511,7 +511,7 @@ # Check for results limit if {$nresults >= $weather_max_results} { - return 0 + return 1 } } @@ -522,10 +522,10 @@ # Check for results limit if {$nresults >= $weather_max_results} { - return 0 + return 1 } } - return 0 + return 1 }