set detikchan "*"
set detiktemp "detik.txt"
set detikupdate 20
timer 1 detikberita
bind pub -|- !detik detikpub
proc detikberita {} {
global detiktimer detikupdate detiktemp tanggal
set url "http://jkt2.detik.com/index.php";
set token "[http::geturl "$url"]"
set data "[http::data $token]"
http::cleanup $token
checktanggal $data
if {$tanggal!=$detiktemp} {
putlog "*** \002detik.com\002 latest news: $tanggal (updating)"
set detiktemp $tanggal
tampilkan $data
} else {
putlog "*** \002detik.com\002 "
}
timer $detikupdate detikberita
}
proc checktanggal {data} {
global detikchan tanggal
foreach d [split $data \n] {
if {[string match "*tanggal*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set tanggal $d
}
}
}
proc tampilkan {data} {
global detikchan
foreach _chan [channels] {
if {[botonchan $_chan]} {
foreach d [split $data \n] {
if {[string match "*tanggal*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set tanggal $d
}
if {[string match "*strJudul*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set judul $d
}
if {[string match "*href*" "$d"]} {
set link "[string range $d [expr [string first "url=" $d] +4] [expr [string first "class" $d] -3] ]"
}
if {[string match "*summary*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set summary $d
puthelp "PRIVMSG $_chan :\0034,9.:DETIK NEWS:. \0039,2$tanggal \0037,2$judul \0038,2$summary \00312,2$link "
break
}
}
} else {
putlog "*** \002detik.com\002: cannot display news on $_chan"
}
}
}
proc detikpub {nick host hand chan text} {
if {![matchattr $nick Q]} {
return 0
}
set url "http://jkt2.detik.com/index.php";
set token "[http::geturl "$url"]"
set data "[http::data $token]"
http::cleanup $token
if {[botonchan $chan]} {
foreach d [split $data \n] {
if {[string match "*tanggal*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set tanggal $d
}
if {[string match "*strJudul*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set judul $d
}
if {[string match "*href*" "$d"]} {
set link "[string range $d [expr [string first "url=" $d] +4] [expr [string first "class" $d] -3] ]"
}
if {[string match "*summary*" "$d"]} {
regsub -all \<\[^\>\]*\> $d "" d
set summary $d
putlog "$tanggal $summary"
putlog "selengkapnya: $link"
puthelp "PRIVMSG $chan :\0034,9.:DETIK NEWS:. \0039,2$tanggal \0037,2$judul \0038,2$summary \00312,2$link "
break
}
}
}
}
proc chk:timer {hand args} {
putlog [timers]
}
bind dcc n|n timer chk:timer
proc kill:timer {idx args} {
set dead [lindex $args 1]
killtimer $dead
putlog "*** Killed timer $dead"
}
set detiktimer [timer $detikupdate detikberita]
putlog "JemBut Detik Loaded!"
Sunday, August 28, 2011
detikcom.tcl
Labels:
tCL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment