changeset 588:dae8f6ad12c2

weather: Fix weather_cmd return values.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 27 Jan 2021 10:24:59 +0200
parents 03d3ec856e4d
children b07ff5123baf
files weather.tcl
diffstat 1 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- 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
 }