accesslist.txt contains just that one line of text.It continuous have the problem.
when i doand i open the file i see this part/msg eirhnh !chanserv sop #parea listCode: Select all
-ChanServ Access List Records-
Code: Select all
-ChanServ Access List Records-
-ChanServ- SOp list for #user
-ChanServ- 1 - Abort (abort@jhb-152-101.tm.net.my)
-ChanServ- 2 - Debora (jaysee@202.158.58.228)
-ChanServ- 3 - FrEe-sTyLe (~FreE-StYL@208.155.67.177)
-ChanServ- 4 - Kevmart (kevmart@noIRC.org)
-ChanServ- 5 - MiRiNdA (mirinda@mirinda.nu)
-ChanServ- 6 - Point (pointzero@pix142166196119.nbtel.net)
-ChanServ- End of list.
Code: Select all
#Set the filename to save the access list records in.
set accesslist "accesslist.txt"
if {![file exists $accesslist]} {
putlog "ACCESS LIST FILE:\002 $accesslist \002file \002does not exist\002, *creating file*: \002$accesslist\002"
set file [open $accesslist "w"]
puts $file "-ChanServ Access List Records-\n"
close $file
}
bind msgm n !chanserv get:access:list
bind notc - save:access:list
proc get:access:list {nick uhost hand text} {
set type [lindex $text 0]; set chan [lindex $text 1]
if {([string equal -nocase "list" [lindex $text 2]])} {
putquick "PRIVMSG chanserv :$type $chan list"
}
}
proc save:access:list {nick uhost hand text {dest ""}} {
global botnick accesslist
if {([string equal -nocase $botnick $dest]) && ([string equal $nick "ChanServ"])} {
if{(([string match "*/[0-9]/*" [lindex $text 0]]) && ([string match "*(*@*)*" [lindex $text 2]])) || ([string match "*list for #*" $text]) || ([string match "*End of List*" $text])} {
if {![file exists $accesslist]} { set file [open $accesslist "w"]; puts $file "-ChanServ Access List Records-\n"; close $file }
set file [open $accesslist "a"]; puts $file $text; close $file; return 0
}
}
}
Code: Select all
#Set the filename to save the access list records in.
set accesslist "accesslist.txt"
if {![file exists $accesslist]} {
putlog "ACCESS LIST FILE:\002 $accesslist \002file \002does not exist\002, *creating file*: \002$accesslist\002"
set file [open $accesslist "w"]
puts $file "-ChanServ Access List Records-\n"
close $file
}
bind msgm n !chanserv get:access:list
bind notc - save:access:list
proc get:access:list {nick uhost hand text} {
set type [lindex $text 0]; set chan [lindex $text 1]
if {([string equal -nocase "list" [lindex $text 2]])} {
putquick "PRIVMSG chanserv :$type $chan list"
}
}
proc save:access:list {nick uhost hand text {dest ""}} {
global botnick accesslist
if {([string equal -nocase $botnick $dest]) && ([string equal $nick "ChanServ"])} {
if {![file exists $accesslist]} { set file [open $accesslist "w"]; puts $file "-ChanServ Access List Records-\n"; close $file }
set file [open $accesslist "a"]; puts $file $text; close $file; return 0
}
}
}
Code: Select all
# File name of the storage file for the access list.
set accesslist "accesslist.txt"
# Full name of channel services
set chanserv "chanserv@Services.dal.net"
# Create the storage file for the access list.
if {![file exists $accesslist]} {
set acc_fd [open $accesslist w]
close $acc_fd
unset acc_fd
if {![file exists $accesslist]} {
putloglev c "*** (notes) ERROR: Unable to write to $accesslist ***"
return 0
}
}
bind pub n test access:list
bind notc - "* list for *" write:list
proc write:list {nick host hand arg {dest ""}} {
set msg [ctrl:filter $arg]
if {[string equal $dest $::botnick]} {
set acc_fd [open $::accesslist a]
puts $acc_fd $msg
close $acc_fd
}
}
proc access:list {nick uhost hand chan text} {
set type [string tolower $text]
if {[string match $type "aop"]} {
putserv "PRIVMSG $::chanserv :aop $chan list"
} else {
putserv "PRIVMSG $::chanserv :sop $chan list"
}
return
}
# ctrl:filter <string>
# Strip all control characters. Thanks to Ppslim.
proc ctrl:filter {str} {
regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
return $str
}
Code: Select all
bind notc - "*list for*" << is good
Code: Select all
bind notc - "*(*@*)*" << ???
[1] Second index is a number. ===> match "*/[0-9/]*"
Code: Select all
proc save:access:list {nick uhost hand text {dest ""}} {
global botnick accesslist
if {([string equal -nocase $botnick $dest]) && ([string equal $nick "ChanServ"])} {
if{((string equal "-" [lindex $text 0]]) && ([string match "*/[0-9]/*" [lindex $text 1]]) && ([string match "*(*@*)*" [lindex $text 3]])) || ([string match -nocase "*list for*" $text]) || ([string match -nocase "*end of list*" $text])} {
if {![file exists $accesslist]} { set file [open $accesslist "w"]; puts $file "-ChanServ Access List Records-\n"; close $file }
set file [open $accesslist "a"]; puts $file $text; close $file; return 0
}
}
}
Try and try.....untill you succeed.Well, nevermind. It dont want to work. I have change and the services to see if the notice of chanserv have something wrong. Thanks for reply all of you,and lets continue programming others tcls.
Code: Select all
#To delete the old file
exec rm $myfile
#To make/open a new file
set deletefile [open $myfile "w"]
#To close and save the file just made
close $deletefile
Why do you keep doing that? Use 'file delete' to delete files.awyeah wrote:exec rm