# like this u can use it to read any line
# usage: readfile <line number>
proc readfile {number} {
set count "0"
set rfile [open "file" "r"]
while {![$rfile]} {
gets $rfile line
set count [expr $count + 1]
if {"$count" == "$number"} {
putlog "This is line $number of ur script: $line" ;#change this line to what u want to do with line
close $rfile
return 1 ;#Or change it to return $line if u want the proc to return the line instead then remove the return 0 and putlog line
}
}
close $rfile
return 0
}
proc linematch {var} {
set rfile [open "file" "r"]
while {![$rfile]} {
gets $rfile line
if {[string match -nocase "*$var*" $line]} {
# your script here....
close $rfile
return 1 ;# This will verrify that the while matched a string
}
}
close $rfile
return 0
}
hehe sorry misread first time ..
Last edited by Ofloo on Sat Feb 21, 2004 8:10 am, edited 1 time in total.
# usage !test /04 or something else of course only checks arg 0,
# if you want it to check more then you have to combine stuff or if u
# wana use spaces well then u got to use lrange ..
bind n !test test:pub
proc test:pub {nick uhost hand chan arg} {
if {[linematch "[lindex $arg 0]"] && ![string match {} [lindex $arg 0]]} {
putserv "PRIVMSG $chan :Found [lindex $arg 0]."
} else {
putserv "PRIVMSG $chan :Nothing Found."
}
}
I should have explained more - there are lots of lines with /04 in it but I only want it to set the first line of /04 as the variable and send it to the channel...