# news.tcl v. 0.0.3 - gets latest news from ghcif.de rss feed # Copyright (C) 2005-2006 Dennis 'key' Meiken # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. bind pub - !news news:data proc news:data {nick userhost hand chan text} { global news if {[catch {set sock [socket www.ghcif.de 80]} sockerror]} { putlog "error: $sockerror" ; return } puts $sock "GET /rss/news.xml HTTP/1.1" puts $sock "User-Agent: ghcif tcl reader" puts $sock "Host: www.ghcif.de" puts $sock "Connection: close" puts $sock "" flush $sock if {[lindex $text 0] == "" } { while {[gets $sock zeile] != -1} { if {[regexp {(.*)} $zeile null news_title]} { if {$news_title != ""} {set f_out_title $news_title} } if {[regexp {(.*)} $zeile null news_link]} { if {$news_link != ""} {set f_out_link $news_link} } if {[regexp {} $zeile]} { set link [string map { & & } $f_out_link] set title [string map { < < } $f_out_title] set ausgabe "$title - $link" putserv "NOTICE $nick : $ausgabe" ; return } } } else { set newsout 1 while {[gets $sock zeile] != -1} { if {$newsout == [expr [lindex $text 0] + 1]} { return } if {[regexp {(.*)} $zeile null news_title]} { if {$news_title != ""} {set f_out_title $news_title} } if {[regexp {(.*)} $zeile null news_link]} { if {$news_link != ""} {set f_out_link $news_link} } if {[regexp {} $zeile]} { set title [string map { < < } $f_out_title] set link [string map { & & } $f_out_link] set ausgabe "$title - $link" putserv "NOTICE $nick : $newsout. $ausgabe" incr newsout } } } } putlog "GHCIF NEWS SCRIPT v0.0.3 written by key successfully loaded"