# HG changeset patch # User Matti Hamalainen # Date 1401789564 -10800 # Node ID 5434903331df2d3c7a45e37941f4464490c4e756 # Parent e4faa3746869e2be9c462d0a0a587ca0e54f9007 weather: Add some comments. diff -r e4faa3746869 -r 5434903331df weather.tcl --- 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