egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help Modifying

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Swinder
Voice


Joined: 10 Aug 2005
Posts: 5

PostPosted: Mon Oct 24, 2005 10:37 am    Post subject: Help Modifying Reply with quote

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:
# 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
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Oct 28, 2005 10:25 am    Post subject: Reply with quote

Code:
# 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>
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber