# HG changeset patch # User Matti Hamalainen # Date 1594286681 -10800 # Node ID b6b92f64013cd8d1368e962765cd2b859a1b22d7 # Parent 47c174bfd9a212ff39b3d922f0db779fe56b729a weather: Reorder function. diff -r 47c174bfd9a2 -r b6b92f64013c weather.tcl --- a/weather.tcl Wed Jul 08 23:51:51 2020 +0300 +++ b/weather.tcl Thu Jul 09 12:24:41 2020 +0300 @@ -22,21 +22,22 @@ ########################################################################## # No need to look below this line ########################################################################## +package require textutil::split + set weather_name "Weather" set weather_version "2.0.0" ### Initialization messages -package require textutil::split set weather_message "$weather_name v$weather_version (C) 2014-2020 ccr/TNSP" putlog "$weather_message" #------------------------------------------------------------------------- -proc weather_log {arg} { +proc weather_log {umsg} { global weather_log_enable weather_name if {$weather_log_enable != 0} { - putlog "$weather_name: $arg" + putlog "$weather_name: $umsg" } } @@ -283,36 +284,6 @@ #------------------------------------------------------------------------- -# Script initialization -#------------------------------------------------------------------------- - -if {![info exists weather_data]} { - array set weather_data {} -} - -if {![info exists weather_aliases]} { - array set weather_aliases {} -} - -if {[info exists weather_running]} { - set weather_last [expr [clock seconds] - $weather_running] -} else { - set weather_last -1 -} - -putlog " - Loading aliases." -weather_load_aliases - -if {$weather_last < 0 || $weather_last > [expr $weather_check_period * 60]} { - putlog " - Starting weather update timer." - weather_exec -} else { - putlog " - Continuing weather updates." - weather_update -} - - -#------------------------------------------------------------------------- proc weather_cmd {unick $uhost uhand uchan uargs upublic} { global weather_default_locations weather_data weather_max_results weather_aliases global weather_msg_list_station weather_msg_result weather_messages @@ -549,7 +520,6 @@ } - #------------------------------------------------------------------------- proc weather_cmd_pub {unick uhost uhand uchan uargs} { global weather_channels @@ -561,9 +531,38 @@ return 0 } -#------------------------------------------------------------------------- proc weather_cmd_msg {unick uhost uhand uargs} { return [weather_cmd $unick $uhost $uhand "PRIV" $uargs 0] } + +#------------------------------------------------------------------------- +# Script initialization +#------------------------------------------------------------------------- + +if {![info exists weather_data]} { + array set weather_data {} +} + +if {![info exists weather_aliases]} { + array set weather_aliases {} +} + +if {[info exists weather_running]} { + set weather_last [expr [clock seconds] - $weather_running] +} else { + set weather_last -1 +} + +putlog " - Loading aliases." +weather_load_aliases + +if {$weather_last < 0 || $weather_last > [expr $weather_check_period * 60]} { + putlog " - Starting weather update timer." + weather_exec +} else { + putlog " - Continuing weather updates." + weather_update +} + # end of script