that post this -> News by nick:
and this i need -> News 16/09-2003:
Code: Select all
# add news
proc nws:addnews {nick uhost handle chan arg} {
global nws
if {$chan != $nws(chan)} {return 0}
set file $nws(file) ; set arg [mirc_strip "$nick $arg"]
set nws(fd) [open $file a+]
puts $nws(fd) $arg
close $nws(fd)
putserv "NOTICE $nick :News has been added"
putcmdlog "<<$nick>> !$handle! Added news in $chan."
return 1
}
# read news
proc nws:news {nick uhost handle chan arg} {
global nws
if {$chan != $nws(chan)} {return 0}
set file $nws(file)
if {![file exists $file]} {putserv "NOTICE $nick :No news found, $file does not exist" ; return}
set nws(fd) [open $file r]
set nws(list) ""
while { ![eof $nws(fd)] } {
set tmp [gets $nws(fd)]
if { $tmp != ""} {lappend nws(list) $tmp }
}
close $nws(fd)
if {[llength $nws(list)] == 0} {putserv "NOTICE $nick :No news found, $file is empty"; return}
set arg [split $arg]
if {$arg=="" || ![string is integer $arg]} {
putserv "NOTICE $nick :[exec grep -c "" $file] news items:"
foreach news $nws(list) {
set place [expr [lsearch -exact $nws(list) $news] + 1]
set name [lindex [split $news] 0]
set comments [expr [llength [split $news |]] - 1]
putserv "NOTICE $nick :$place.\002 [lrange [split $news] 1 4]...\002 ($comments comments)"
}
} else {
if {$arg > [llength $nws(list)] || $arg <= 0} {return}
set news [split [lindex [split [lindex $nws(list) [expr $arg - 1]] |] 0]]
set cmnt [lrange [split [lindex $nws(list) [expr $arg - 1]] |] 1 end]
putserv "NOTICE $nick :\002News\002 by \002[lindex $news 0]\002: [lrange $news 1 end]"
foreach line $cmnt {
putserv "NOTICE $nick :\002Comment\002 by \002[lindex [split $line] 1]\002: [lrange [split $line] 2 end]"
}
}
}