1) It says nick not found in the database (text file)
2) The database file containing all the nicks becomes empty.
I need these two errors to be fixed if possible, for the script to work fine. Can anyone help me to rectify these errors if possible?
Here is the testing I did:
<awyeah> .aovadd AhB
<adapter> AhB has been successfully added to the AOv list.
* adapter sets mode: +v-k AhB Added.to.AOv.list
<awyeah> .aovdel AhB
<adapter> AhB has been successfully removed from the AOv list.
* adapter sets mode: -vk AhB Removed.from.AOv.list
<awyeah> .aovadd [Nadia]
* adapter sets mode: +v-k [Nadia] Added.to.AOv.list
<awyeah> .aovdel [Nadia]
<adapter> [Nadia] was not found in the AOv list.
<awyeah> .aovlist
-adapter- AOv list for #pak
-adapter- 1 - \[Nadia\] (aov@pak.dal.net)
-adapter- End of list.
Text file contains this entry:
[Nadia]:#pak
Is my code okay and proper for deleting a specified nick from the database file? Also and suggestions on how to fix the script, so it deletes nicks with special characters from the database file??adapter- AOv list for #pak
-adapter- 1 - \[Nadia\] (aov@klsex.dal.net)
-adapter- 2 - \[DeV-Kl\] (aov@klsex.dal.net)
-adapter- End of list.
<awyeah> .delaov [Nadia]
<adapter> [Nadia] was not found in the AOv list of #pak.
<awyeah> .listaov
-adapter- AOv list for #pak
-adapter- End of list.
Here is my code:
Code: Select all
proc aov:add {nick uhost hand chan arg} {
global aov sov
set arg [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $arg]
if {$arg != ""} {
set fp [open $sov r+]
set data [read -nonewline $fp]
close $fp
set list [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
if {[lsearch -exact [string tolower $list] [string tolower [lindex $arg 0]]:[string tolower $chan]] != -1} {
putserv "PRIVMSG $chan :You are already a SOv on [string tolower $chan]. You cannot add yourself to the AOv list of [string tolower $chan]."
return 0
}
if {([lsearch -exact [string tolower $list] [string tolower $nick]:[string tolower $chan]] != -1) || [matchattr $hand mn|mn $chan]} {
set user [lindex $arg 0]:[string tolower $chan]
set fp [open $aov r+]
set data [read -nonewline $fp]
close $fp
set list2 [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
if {[lsearch -exact [string tolower $list2] [string tolower $user]] == -1} {
set file [open $aov a+]
puts $file $user
close $file
putserv "PRIVMSG $chan :[lindex $arg 0] has been successfully added to the AOv list of [string tolower $chan]."
utimer 3 [list aov:on:add [lindex $arg 0] $chan]
return 0
} else {
putserv "PRIVMSG $chan :[lindex $arg 0] already exists on the AOv list of [string tolower $chan]."
return 0
}
} else {
putserv "PRIVMSG $chan :You do not have access to modify the AOv list of [string tolower $chan]."; return 0
}
}
}
proc aov:delete {nick uhost hand chan arg} {
global aov sov
set arg [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $arg]
if {[info exists list3]} { unset list3 }
if {$arg != ""} {
set fp [open $sov r+]
set data [read -nonewline $fp]
close $fp
set list [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
set fp [open $aov r+]
set data [read -nonewline $fp]
close $fp
set list2 [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
if {([lsearch -exact [string tolower $list] [string tolower $nick]:[string tolower $chan]] != -1) || ([lsearch -exact [string tolower $list2] [string tolower $nick]:[string tolower $chan]] != -1) || [matchattr $hand mn|mn $chan]} {
set user [lindex $arg 0]:[string tolower $chan]
set fp [open $aov r+]
set data [read -nonewline $fp]
close $fp
set list3 [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
set fd [open $aov w+]
if {[set i [lsearch -exact [string tolower $list3] [string tolower $user]]] != -1} {
set fd [open $aov w+]
puts -nonewline $fd [join [lreplace $list3 $i $i] \n]
close $fd
putserv "PRIVMSG $chan :[lindex $arg 0] has been successfully removed from the AOv list of [string tolower $chan]."
utimer 3 [list aov:on:del [lindex $arg 0] $chan]
} else {
putserv "PRIVMSG $chan :[lindex $arg 0] was not found in the AOv list of [string tolower $chan]."
return 0
}
} else {
putserv "PRIVMSG $chan :You do not have access to modify the AOv list of [string tolower $chan]."
}
if {[info exists list3]} { close $fd; unset list3; return 0 }
}
}
Code: Select all
proc sov:wipe {nick uhost hand chan arg} {
global aov sov
set fp [open $sov r+]
set data [read -nonewline $fp]
close $fp
set list [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
if {[matchattr $hand mn|mn $chan]} {
set fd [open $sov w+]
set list3 [list]
foreach user $list {
if {[set i [lsearch -exact [string tolower $list] [string tolower $user]]] != -1} {
set list3 [lreplace $list3 $i $i]
}
}
puts -nonewline $fd [join $list3 "\n"]
putserv "PRIVMSG $chan :The SOv list of [string tolower $chan] has been wiped successfully."
close $fd
}
set fp [open $aov r+]
set data [read -nonewline $fp]
close $fp
set list2 [split [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\}} $data]]
if {([lsearch -exact [string tolower $list] [string tolower $nick]:[string tolower $chan]] != -1) || ([lsearch -exact [string tolower $list2] [string tolower $nick]:[string tolower $chan]] != -1)} {
putserv "PRIVMSG $chan :You do not have access to wipe the SOv list of [string tolower $chan]."
return 0
}
}