Hi this script was made for another user on this forum, i was wondering if someone would be so kind to make it available for public usage so it wouldn't have to be msg'd to the eggdrop, also a possible delete function? The delete function would delete the whole users line of information, once again this would publicly accessible
# File
set bncinfofile "scripts/bncinfo.txt"
# Information
set bncinfo {name email password}
bind msg n bncadd bnc:info:add
bind msg n bncget bnc:info:get
proc bnc:info:add {nick uhost hand arg} {
global bncinfofile bncinfo
set c 0
foreach i $bncinfo {
append info "$i: [lindex [split $arg] $c] "
incr c
}
puts [set f [open $bncinfofile a]] $info
close $f
}
proc bnc:info:get {nick uhost hand arg} {
global bncinfofile
foreach i [split [read [set f [open $bncinfofile]]] \n][close $f] {
if {[string equal -nocase [lindex $i 1] [lindex [split $arg] 0]]} {
puthelp "notice $nick :$i" ; set found 1
break
}
}
if {![info exists found]} {
puthelp "notice $nick :[lindex [split $arg] 0] was not found in the DB."
}
}
# File
set bncinfofile "scripts/bncinfo.txt"
# Information
set bncinfo {name email password}
bind pub n !bncadd bnc:info:add
bind pub n !bncget bnc:info:get
bind pub n !bncdel bnc:info:del
proc bnc:info:add {nick uhost hand chan arg} {
global bncinfofile bncinfo
set c 0
foreach i $bncinfo {
append info "$i: [lindex [split $arg] $c] "
incr c
}
puts [set f [open $bncinfofile a]] $info
close $f
}
proc bnc:info:get {nick uhost hand chan arg} {
global bncinfofile
foreach i [split [read [set f [open $bncinfofile]]] \n][close $f] {
if {[string equal -nocase [lindex $i 1] [lindex [split $arg] 0]]} {
puthelp "notice $nick :$i" ; set found 1
break
}
}
if {![info exists found]} {
puthelp "notice $nick :[lindex [split $arg] 0] was not found in the DB."
}
}
proc bnc:info:del {nick uhost hand chan arg} {
global bncinfofile
set name [lindex [split $arg] 0]
set i 0
foreach user [split [read [set inf [open $bncinfofile]]] "\n"][close $inf] {
if {[string equal -nocase [lindex $user 1] $name]} { set f 1 ; break }
incr i
}
if {[info exists f]} {
replaceLines $bncinfofile $i $i
puthelp "notice $nick :Deleted $name from db."
} {
puthelp "notice $nick :$name was not found in db."
}
}
# proc by user
proc replaceLines {args} {
if {[llength $args]>=3} {
foreach {file start end} $args break
set cmd [list lreplace [split [read [set f [open $file r]]] \n] $start $end]
close $f
if {[llength $args]>3} {lappend cmd [lindex $args 3]}
puts -nonewline [set f [open $file w]] [join [eval $cmd] \n]
close $f
} {
error "wrong # args: should be \"[lindex [info level 0] 0] file start end ?replacement?\""
}
}