changeset 171:5434903331df

weather: Add some comments.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Jun 2014 12:59:24 +0300
parents e4faa3746869
children 2c89e47739e8
files weather.tcl
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/weather.tcl	Tue Jun 03 12:58:46 2014 +0300
+++ b/weather.tcl	Tue Jun 03 12:59:24 2014 +0300
@@ -162,6 +162,7 @@
 }
 
 
+# If there exists an alias for given string/name, return it
 proc weather_get_alias {uname} {
   global weather_aliases
   set utmp [array get weather_aliases $uname]
@@ -181,6 +182,8 @@
   return ""
 }
 
+
+# Produce one location of weather data as a string
 proc weather_get_data {ukey udata} {
   set str "\002[lindex $udata 0]\002, mitattu klo [weather_ctime [lindex $udata 1]]: \002[lindex $udata 2]°C\002"
   append str [weather_item $udata 4 ", @@"]
@@ -190,6 +193,7 @@
 }
 
 
+# Get data by location key
 proc weather_get_key {ukey} {
   global weather_data
   return [weather_get_data $ukey $weather_data($ukey)]
@@ -244,6 +248,7 @@
 
 
 #-------------------------------------------------------------------------
+# Weather data update loop
 proc weather_exec {} {
   global weather_check_period weather_running 
 
@@ -257,6 +262,9 @@
 
 
 #-------------------------------------------------------------------------
+# Script initialization
+#-------------------------------------------------------------------------
+
 if {![info exists weather_data]} {
   array set weather_data {}
 }
@@ -300,8 +308,9 @@
     return 0
   }
   
-  # Setting the location
+  # List or set the default weather station name patterns for this user
   if {$rarg == "vakio" || $rarg == "default" || $rarg == "vakiot"} {
+    # Access check
     if {![weather_valid_user $uhand]} {
       weather_msg $upublic $unick $uchan $weather_msg_user_not_known
       return 0
@@ -329,6 +338,7 @@
     }
     return 0
   } elseif {$rarg == "alias"} {
+    # Alias a string to another, only certain users have access (+n flag)
     if {![weather_valid_user $uhand] || ![matchattr $uhand n]} {
       weather_msg $upublic $unick $uchan $weather_msg_no_access
       return 0
@@ -349,6 +359,7 @@
     weather_save_aliases
     return 0
   } elseif {$rarg == "unalias"} {
+    # Remove one alias, only certain users have access (+n flag)
     if {![weather_valid_user $uhand] || ![matchattr $uhand n]} {
       weather_msg $upublic $unick $uchan $weather_msg_no_access
       return 0