Mercurial > hg > egg-tcls
changeset 555:b6b92f64013c
weather: Reorder function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Jul 2020 12:24:41 +0300 |
parents | 47c174bfd9a2 |
children | e310d223dd12 |
files | weather.tcl |
diffstat | 1 files changed, 34 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- 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