annotate feeds.tcl @ 415:ff932030a9b3

weather: Bump version.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 07 Jan 2017 22:41:07 +0200
parents 9a33575eb999
children 880a07485275
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
1 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #
323
9380535b8f12 feeds: Bump version.
Matti Hamalainen <ccr@tnsp.org>
parents: 265
diff changeset
3 # FeedCheck v1.0 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
265
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
4 # (C) Copyright 2008-2015 Tecnic Software productions (TNSP)
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 #
265
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
6 # Requires fetch_feeds.tcl to be run as a cronjob, for example
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
7 # 15 * * * * /absolute/path/to/fetch_feeds.tcl
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #
145
c94b4e1a2ed4 Rename some files, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
9 # See also create_feeds_db.tcl OR convert_feeds_db.tcl, as you will
c94b4e1a2ed4 Rename some files, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
10 # need to either create a SQLite3 database or convert old text flat
c94b4e1a2ed4 Rename some files, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
11 # file to SQLite3.
c94b4e1a2ed4 Rename some files, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 144
diff changeset
12 #
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 # This script is freely distributable under GNU GPL (version 2) license.
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 #
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
15 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
265
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
17 ### The configuration should be in config.feeds in same directory
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
18 ### as this script. Or change the line below to point where ever
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
19 ### you wish. See "config.feeds.example" for an example config file.
908edc54005a feeds: Move configuration to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents: 226
diff changeset
20 source [file dirname [info script]]/config.feeds
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
23 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 # No need to look below this line
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
25 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 set feeds_name "FeedCheck"
323
9380535b8f12 feeds: Bump version.
Matti Hamalainen <ccr@tnsp.org>
parents: 265
diff changeset
27 set feeds_message "$feeds_name v1.0 by ccr/TNSP"
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 putlog "$feeds_message"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 bind pub - !feeds feeds_pubfetch
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 bind pub - !last feeds_publast
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
34 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
35 proc feeds_escape { str } {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
36 return [string map {' ''} $str]
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
37 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
38
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 proc feeds_smsg {uchan umsg} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 global feeds_preferredmsg
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 putserv "$feeds_preferredmsg $uchan :$umsg"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 proc feeds_log {umsg} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 global feeds_name
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 putlog "$feeds_name: $umsg"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
49 proc feeds_msg {utime ufeed uurl utitle} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 global feeds_channels
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 foreach {uchan ufilter} [array get feeds_channels] {
143
96b42289f1e7 Fixes in feeds checker.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
52 foreach umatch [split $ufilter "|"] {
96b42289f1e7 Fixes in feeds checker.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
53 if {[string match -nocase $umatch $ufeed]} {
226
0ff78e418e77 feeds: Don't add # to channel names automatically.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
54 feeds_smsg "$uchan" "$ufeed: \002$utitle\002 -- $uurl"
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 proc feeds_ctime {utime} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 if {$utime == "" || $utime == "*"} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 set utime 0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 return [clock format $utime -format "%d.%m.%Y %H:%M"]
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
68 ### Open database, etc
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
69 if {[catch {sqlite3 feeds_dbh $feeds_dbfile} uerrmsg]} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
70 puts "Could not open SQLite3 database '$feeds_dbfile': $uerrmsg."
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
71 exit 2
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
72 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
73
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
74
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
75 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
76 proc feeds_check_start {} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
77 global feeds_dbfile
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
78
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 set oldtime 0
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
80 if {![catch {set ufile [open "$feeds_dbfile.time" r 0600]} uerrmsg]} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 gets $ufile oldtime
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 close $ufile
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 } else {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 feeds_log "Could not open timefile: $uerrmsg"
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
85 set oldtime [clock seconds]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 }
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
87
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
88 return $oldtime
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
89 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
90
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
91
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
92 proc feeds_check_end {} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
93 global feeds_dbfile
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
95 if {![catch {set ufile [open "$feeds_dbfile.time" w 0600]} uerrmsg]} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
96 puts $ufile [clock seconds]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 close $ufile
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
101 # ------------------------------------------------------------------------
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 proc feeds_exec {} {
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
103 global feeds_dbh feeds_check_period feeds_running feeds_sync_limit
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
104
146
7106dd8db4de Improve entity parsing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
105 # feeds_log "Timed feed check."
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
106 set oldtime [feeds_check_start]
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
107
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
108 set usql "SELECT feed AS ufeed, title AS utitle, url AS uurl, utime AS utime FROM feeds WHERE utime > $oldtime ORDER BY utime ASC"
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
109 set nresult [feeds_dbh onecolumn "SELECT COUNT(*) FROM feeds WHERE utime > $oldtime"]
361
299cdd79b7ee feeds: Fix some limit checks.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
110 if {$nresult > $feeds_sync_limit} {
393
9a33575eb999 feeds: Improve logging.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
111 feeds_log "$nresult new entries, probably unsynchronized. Ignoring."
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
112 } else {
393
9a33575eb999 feeds: Improve logging.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
113 feeds_log "$nresult new entries since $oldtime .."
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
114 feeds_dbh eval $usql {
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
115 feeds_msg $utime $ufeed $uurl $utitle
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
116 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 }
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
118
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
119 if {$nresult > 0} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
120 feeds_check_end
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
121 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
122
144
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
123 set feeds_running [clock seconds]
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
124 timer $feeds_check_period feeds_exec
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
146
7106dd8db4de Improve entity parsing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
127
144
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
128 if {[info exists feeds_running]} {
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
129 set feeds_last [expr [clock seconds] - $feeds_running]
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
130 } else {
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
131 set feeds_last -1
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
132 }
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
133
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
134 if {$feeds_last < 0 || $feeds_last > [expr $feeds_check_period * 60]} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 feeds_log "Starting timed feed check."
154
7a549487fba3 feeds: Cleanups, minor bugfix in feed update checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 146
diff changeset
136 feeds_exec
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
139
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
140 # ------------------------------------------------------------------------
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 proc feeds_pubfetch {unick uhost uhand uchan utext} {
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
142 global feeds_dbh feeds_sync_limit
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
143 # feeds_log "Manual check invoked on $uchan."
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
144
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
145 set oldtime [feeds_check_start]
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
146 set nresult [feeds_dbh onecolumn "SELECT COUNT(*) FROM feeds WHERE utime > $oldtime"]
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
147
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 if {$nresult > 0} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
149 feeds_check_end
361
299cdd79b7ee feeds: Fix some limit checks.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
150 if {$nresult > $feeds_sync_limit} {
351
0f55bbb7fea3 feeds: Improve safety checks and add new configuration setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 323
diff changeset
151 feeds_smsg $uchan "$nresult uutta, tod. näk. epäsynkissä. Ignoorataan."
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 } else {
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
153 set usql "SELECT feed AS ufeed, title AS utitle, url AS uurl, utime AS utime FROM feeds WHERE utime > $oldtime ORDER BY utime ASC"
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
154 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
155 feeds_msg $utime $ufeed $uurl $utitle
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
156 set found 1
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
157 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 feeds_smsg $uchan "$nresult uutta."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 } else {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 feeds_smsg $uchan "Ei uusia."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
166 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
167 proc feeds_publast {unick uhost uhand uchan utext} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
168 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
169 set ufound 0
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
170
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
171 set usql "SELECT url AS uurl, feed AS ufeed, title AS utitle, utime AS utime FROM feeds WHERE feed LIKE '%[string tolower [feeds_escape $utext]]%' ORDER BY utime DESC LIMIT 1"
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
172 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
173 feeds_smsg $uchan "Uusin '$ufeed' / [feeds_ctime $utime]: $utitle -- $uurl"
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
174 set ufound 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
177 if {$ufound == 0} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 feeds_smsg $uchan "Ei osumia haulla '$utext'."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 }