Hallo
I have this Script but i have a few change to it or somone noes where to find another one
1 need to Put in the script so user kan write navn?
2 Can it be possible to set in the script waht channel there works whit ? navn or navn? og what channel i can learn the stuff in
The script is here
putlog "Learn v1.0 by Nite"
set learnfile "/sti/$botnick.learn"
bind pub o|o !learn pub:learn
#bind msg o|o !learn msg:learn
bind pub - "?" pub:learned
#bind msg o|o "?" msg:learned
bind pub - "??" pub:learned
#bind msg o|o "??" msg:learned
bind pub o|o !forget pub:forget
#bind msg o|o !forget msg:forget
# Tcl chokes on this for unknown reasons. *sigh*
proc ctoken {str delim} {
set index [string match [$delim] $str]
set token [string range $str 0 $index]
set strvar [string range $str $index [string length $str] ]
return $token
}
# Tcl barfs on this on two. Who knows why?
proc msg:learn {nick host hand args} {
pub:learn {$nick $host $hand "" $args}
}
proc pub:learn {nick host hand chan args} {
global learnfile
set args [string trim $args "{} "]
# Seperate the first word from the rest of the line.
# Should be: set word [ctoken $args " "]
set len [string length $args]
if {$len == 0} {
putserv "PRIVMSG $chan $nick :How am I to learn that? No Way!"
return
}
set space [string first " " $args]
if {$space == -1} {
putserv "PRIVMSG $chan $nick :Hey, you did it wrong! Go to
school!"
return
}
set word [string trim [string range $args 0 $space] ]
set learn [string trim [string range $args $space $len] ]
# Add it into the *.learn file.
set file [open $learnfile a+]
puts $file "${word}::$learn"
close $file
putserv "PRIVMSG $chan $nick :$word... Okay."
}
proc pub:learned {nick host hand chan args} {
global learnfile
set found 0
set args [string trim $args "{} "]
if {[string length $args] == 0} {
putserv "NOTICE $nick :Eh? Try '? help'"
return
}
if [file readable $learnfile] {
set file [open $learnfile RDONLY]
while {1} {
if [eof $file] break
set line [gets $file]
# Get the word. Should be: set word [ctoken $line ":"]
set len [string length $line]
set colon [string first ":" $line]
set word [string range $line 0 [expr $colon -1] ]
set line [string range $line [expr $colon +1] $len]
# Get the flags. Should be: set flags [ctoken $line ":"]
set len [string length $line]
set colon [string first ":" $line]
set flags [string range $line 0 [expr $colon -1] ]
set line [string range $line [expr $colon +1] $len]
if {[string compare $args $word] == 0} {
putserv "PRIVMSG $chan :$word == $line"
incr found
}
}
close $file
} else {
putserv "NOTICE $nick :But I don't know anything!"
return
}
if {$found == 0} {
putserv "NOTICE $nick :$args? What are you jabbering about?"
}
}
# copyfile doesn't work. frename doesn't work. I hate kludges!
proc pub:forget {nick host hand chan args} {
global learnfile
set found 0
set args [string trim $args "{} "]
if {[string length $args] == 0} {
putserv "NOTICE $nick :I don't remember what you wanted me to
forget."
return
}
# Step one: Create a new file without the $args keyword.
if [file readable $learnfile] {
set file [open $learnfile RDONLY]
set newfile [open $learnfile.tmp w]
while {1} {
if [eof $file] break
set line [gets $file]
# Get the word. Should be: set word [ctoken $line ":"]
set len [string length $line]
set colon [string first ":" $line]
set word [string range $line 0 [expr $colon -1] ]
set line [string range $line [expr $colon] $len]
if {[string compare $args $word]} {
puts $newfile "$word$line"
} else {
incr found
}
}
close $file
close $newfile
} else {
putserv "NOTICE $nick :But I don't know anything!"
return
}
if {$found == 0} {
putserv "PRIVMSG $chan $nick :But I have no idea what \"$args\" is!"
return
}
# Step two: Rewrite the $learnfile from the new file.
set file [open $learnfile w]
set newfile [open $learnfile.tmp r]
while { 1 } {
if [eof $newfile] break
puts $file [gets $newfile]
}
close $file
close $newfile
putserv "PRIVMSG $chan $nick :Oh no! I just forgot what \"$args\" was!"
}