annotate feeds.tcl @ 142:4c51eeba993f

Rename table.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Jun 2013 20:49:13 +0300
parents c99df41a691a
children 96b42289f1e7
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
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
58 feeds_log "$utime $ufeed $uurl $utitle"
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 foreach {uchan ufilter} [array get feeds_channels] {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 foreach umatch [split [string tolower $ufilter] "|"] {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
61 if {[string match $umatch $ufeed]} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
62 feeds_smsg "#$uchan" "$ufeed: \002$utitle\002 -- $uurl"
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 }
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
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 proc feeds_ctime {utime} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 if {$utime == "" || $utime == "*"} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 set utime 0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 return [clock format $utime -format "%d.%m.%Y %H:%M"]
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
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 ### Open database, etc
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
77 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
78 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
79 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
80 exit 2
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
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
83
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
84 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
85 proc feeds_check_start {} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
86 global feeds_dbfile
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
87
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 set oldtime 0
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
89 if {![catch {set ufile [open "$feeds_dbfile.time" r 0600]} uerrmsg]} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 gets $ufile oldtime
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 close $ufile
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 } else {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 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
94 set oldtime [clock seconds]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 }
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
96
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
97 return $oldtime
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
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
101 proc feeds_check_end {} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
102 global feeds_dbfile
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
104 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
105 puts $ufile [clock seconds]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 close $ufile
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
110 # ------------------------------------------------------------------------
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 proc feeds_exec {} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
112 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
113
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
114 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
115 set found 0
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
116
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
117 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
118 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
119 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
120 set found 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 }
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
122
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
123 if {$found} {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
124 feeds_check_end
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
125 }
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
126
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 timer 5 feeds_exec
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 if {![info exists feeds_running]} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 feeds_log "Starting timed feed check."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 timer 5 feeds_exec
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 set feeds_running 1
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
136
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
137 # ------------------------------------------------------------------------
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 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
139
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
140 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
141 # 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
142
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
143 set oldtime [feeds_check_start]
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
144 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
145
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 if {$nresult > 0} {
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
147 feeds_check_end
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 if {$nresult >= 20} {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 feeds_smsg $uchan "$nresult uutta, tod. näk. epäsynkissä. Ignoorataan."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 } else {
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
151 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
152 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
153 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
154 set found 1
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
155 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 feeds_smsg $uchan "$nresult uutta."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 } else {
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 feeds_smsg $uchan "Ei uusia."
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
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
164 # ------------------------------------------------------------------------
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
165 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
166 global feeds_dbh
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
167 set ufound 0
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
168
142
4c51eeba993f Rename table.
Matti Hamalainen <ccr@tnsp.org>
parents: 141
diff changeset
169 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
170 feeds_dbh eval $usql {
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
171 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
172 set ufound 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
141
c99df41a691a Work on making the feeds script use the SQLite3 backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
175 if {$ufound == 0} {
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 feeds_smsg $uchan "Ei osumia haulla '$utext'."
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 }