Code: Select all
# www.linux-on-line.net backend eggdrop script
# linuxnews.tcl - requesting and displaying info
# Copyright (C) 2003 Sheyh [irc.sheyh.com], www.linux-on-line.net
# Greets goes to CoolCold [irc.rea.ru]
# $Id: linuxnews.tcl v 1.0 23/07/2003 12:32:15 Sheyh Exp $
# 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.
# HOWTo use:
# type !news in channel (or you can change it at next line), bot will
# diplay news in channel no more than once every 2 hours (noone likes flood),
# all other time it will send private notices. lynx is required for script to work.
# For any questions please contact me on IRC [irc.sheyh.com] #linux
bind pub - "!news" proc_listnews
proc proc_listnews {nnick uhost hand chan arg} {
putlog "requesting http://linux-on-line.net news"
readnewslist $nnick $chan
}
set saidtime unixtime
set temp 0
set gotpublic 0
proc readnewslist {nnick chan} {
global saidtime
global temp
global gotpublic
catch { set res [exec lynx -source http://linux-on-line.net/backend/eggnews.php ] }
if { $res == "" } {
putserv "PRIVMSG $chan :can't connect to linux-on-line.net :(."
return
}
set res [split $res \n]
set line ""
for {set i 0} {"[lindex $res $i]" != ""} {
incr i
} {
if {$i > 20} { break }
set line ""
set line "$line[lindex $res $i]"
set timenow unixtime
set temp_timenow [$timenow]
if { $i != 0 } {
set timediff [expr $temp_timenow - $temp]
if {$timediff > 7200} {
set gotpublic 1
putserv "PRIVMSG $chan : $line "
} else {
putserv "NOTICE $nnick : $line "
set gotpublic 0
}
} else {
if { $line != "access1granted " } {
putserv "PRIVMSG $chan : hm...looks like i've stolen this script from http://linux-on-line.net/backend/ :( "
break
}
}
}
if {$gotpublic > 0} {
set saidtime unixtime
set temp [$saidtime]
}
}
<SnowStalker> [15:24] requesting http://linux-on-line.net news
<SnowStalker> [15:24] Tcl error [proc_listnews]: can't read "res": no such variable