This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Help Modifying

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
S
Swinder
Voice
Posts: 5
Joined: Wed Aug 10, 2005 6:00 am

Help Modifying

Post by Swinder »

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

Code: Select all

# 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."
 }
}
Thanks
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

# 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?\"" 
 } 
}
For deleting use: !bncdel <name>
Post Reply