annotate feeds.tcl @ 143:96b42289f1e7

Fixes in feeds checker.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Jun 2013 22:01:39 +0300
parents 4c51eeba993f
children 824d24f20826
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 #
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
3 # FeedCheck v0.8 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
4 # (C) Copyright 2008-2013 Tecnic Software productions (TNSP)
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 #
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 # Requires get_feeds.tcl to be run as a cronjob, for example
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 # 15 * * * * /absolute/path/to/get_feeds.tcl
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 # This script is freely distributable under GNU GPL (version 2) license.
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
11 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
13 # SQLite3 database, MUST be set to same as in feeds.tcl
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
14 set feeds_dbfile "/home/niinuska/bot/feeds.sqlite"
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
15
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 # Set channels and feed filters here:
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 # "channel" "feedname|feedname2"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 # feednames can use matching, e.g. "mtv3*" would match all beginning with "mtv3"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 array set feeds_channels {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 "mazmlame" "the adventurers|oots|mestari|blastwave"
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
22 "fireball" "mestari|mtv3/rikos"
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 "tnsp" "the adventurers|oots|mestari"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 set feeds_preferredmsg "PRIVMSG"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
30 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 # No need to look below this line
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
32 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 set feeds_name "FeedCheck"
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
34 set feeds_message "$feeds_name v0.8 by ccr/TNSP"
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 putlog "$feeds_message"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 bind pub - !feeds feeds_pubfetch
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 bind pub - !last feeds_publast
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
41 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
42 proc feeds_escape { str } {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
43 return [string map {' ''} $str]
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
44 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
45
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 proc feeds_smsg {uchan umsg} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 global feeds_preferredmsg
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 putserv "$feeds_preferredmsg $uchan :$umsg"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 proc feeds_log {umsg} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 global feeds_name
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 putlog "$feeds_name: $umsg"
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
56 proc feeds_msg {utime ufeed uurl utitle} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 global feeds_channels
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 foreach {uchan ufilter} [array get feeds_channels] {
143
96b42289f1e7 Fixes in feeds checker.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
59 foreach umatch [split $ufilter "|"] {
96b42289f1e7 Fixes in feeds checker.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
60 if {[string match -nocase $umatch $ufeed]} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
61 feeds_smsg "#$uchan" "$ufeed: \002$utitle\002 -- $uurl"
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 }
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 proc feeds_ctime {utime} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 if {$utime == "" || $utime == "*"} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 set utime 0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 return [clock format $utime -format "%d.%m.%Y %H:%M"]
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
75 ### Open database, etc
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
76 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
77 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
78 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
79 exit 2
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
80 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
81
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
82
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
83 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
84 proc feeds_check_start {} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
85 global feeds_dbfile
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
86
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 set oldtime 0
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
88 if {![catch {set ufile [open "$feeds_dbfile.time" r 0600]} uerrmsg]} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 gets $ufile oldtime
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 close $ufile
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 } else {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 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
93 set oldtime [clock seconds]
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
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
96 return $oldtime
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
97 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
98
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
99
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
100 proc feeds_check_end {} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
101 global feeds_dbfile
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
103 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
104 puts $ufile [clock seconds]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 close $ufile
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
109 # ------------------------------------------------------------------------
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 proc feeds_exec {} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
111 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
112
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
113 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
114 set found 0
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
115
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
116 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
117 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
118 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
119 set found 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 }
141
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 if {$found} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
123 feeds_check_end
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
124 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
125
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 timer 5 feeds_exec
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 if {![info exists feeds_running]} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 feeds_log "Starting timed feed check."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 timer 5 feeds_exec
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 set feeds_running 1
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
135
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
136 # ------------------------------------------------------------------------
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 proc feeds_pubfetch {unick uhost uhand uchan utext} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
138
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
139 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
140 # 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
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
142 set oldtime [feeds_check_start]
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
143 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
144
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 if {$nresult > 0} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
146 feeds_check_end
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 if {$nresult >= 20} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 feeds_smsg $uchan "$nresult uutta, tod. näk. epäsynkissä. Ignoorataan."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 } else {
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
150 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
151 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
152 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
153 set found 1
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
154 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 feeds_smsg $uchan "$nresult uutta."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 } else {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 feeds_smsg $uchan "Ei uusia."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
163 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
164 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
165 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
166 set ufound 0
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
167
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
168 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
169 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
170 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
171 set ufound 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
174 if {$ufound == 0} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 feeds_smsg $uchan "Ei osumia haulla '$utext'."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 }