Mercurial > hg > egg-tcls
changeset 144:824d24f20826
Fixes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Jun 2013 15:49:47 +0300 |
parents | 96b42289f1e7 |
children | c94b4e1a2ed4 |
files | feeds.tcl |
diffstat | 1 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/feeds.tcl Tue Jun 04 22:01:39 2013 +0300 +++ b/feeds.tcl Wed Jun 05 15:49:47 2013 +0300 @@ -13,13 +13,18 @@ # SQLite3 database, MUST be set to same as in feeds.tcl set feeds_dbfile "/home/niinuska/bot/feeds.sqlite" +# How often to check for newly added feed items from the database? +# (in minutes) This has nothing to do how often the backend script +# is run and actually scans / pulls the feeds, that is done in CRON. +# See get_feeds.tcl for more information. +set feeds_check_period 5 # Set channels and feed filters here: # "channel" "feedname|feedname2" # feednames can use matching, e.g. "mtv3*" would match all beginning with "mtv3" array set feeds_channels { "mazmlame" "the adventurers|oots|mestari|blastwave" - "fireball" "mestari|mtv3/rikos" + "fireball" "mestari" "tnsp" "the adventurers|oots|mestari" } @@ -73,7 +78,6 @@ ### Open database, etc -global feeds_dbh if {[catch {sqlite3 feeds_dbh $feeds_dbfile} uerrmsg]} { puts "Could not open SQLite3 database '$feeds_dbfile': $uerrmsg." exit 2 @@ -108,8 +112,9 @@ # ------------------------------------------------------------------------ proc feeds_exec {} { - global feeds_dbh + global feeds_dbh feeds_check_period + feeds_log "Timed feed check." set oldtime [feeds_check_start] set found 0 @@ -123,13 +128,20 @@ feeds_check_end } - timer 5 feeds_exec + set feeds_running [clock seconds] + timer $feeds_check_period feeds_exec } -if {![info exists feeds_running]} { +if {[info exists feeds_running]} { + set feeds_last [expr [clock seconds] - $feeds_running] +} else { + set feeds_last -1 +} + +if {$feeds_last < 0 || $feeds_last > [expr $feeds_check_period * 60]} { feeds_log "Starting timed feed check." - timer 5 feeds_exec - set feeds_running 1 + timer $feeds_check_period feeds_exec + set feeds_running [clock seconds] }