So if/when i restart the bot it loads from the db and shows the definition with those {} around "hell ya" in the channel.
I've tried looking around in the script but this is a bit more then i can get through my head. Can anyone take a quick look or clue me in what to look for. I really like the script otherwise but this is kinda a showstopper since people do use special characters when adding definitions.
Thanks for the reply but if i understand you correctly that seems more like a fix then a solution to the problem. This is the part of the script that adds the definitions to the in memory db:
bind pub $dictionary(addflag) $dictionary(addtrigger) dic:pub:add
proc dic:pub:add {nick uhost handle chan text} {
global dictionary
if {$dictionary(dicmchanonly)==1 && [lsearch -exact [channel info $chan] +dicm]==-1} { return 0 }
if {[dic:check:flood $handle]} { return 0 }
set str [dic:intr:add $text]
set word [lindex $str 0]
set def [lindex $str 1]
if {$def==""} { putserv "PRIVMSG $chan :Error, no definition given." ; return 0 }
dic:add $nick $word $def
putlog "$nick@$chan $dictionary(addtrigger) $text"
if {$dictionary(quiret) == 0 && [dic:ishub $chan]} {
if {$dictionary(where)==1} { putserv "PRIVMSG $chan :Added $word=$def" }
if {$dictionary(where)==2} { putserv "NOTICE $nick :Added $word=$def" }
}
}
proc dic:intr:add {line} {
#input a string, as the user typed it.
#output a list with 2 parts, word, def
if {[string range $line 0 0]=="\""} {
set found [join [lindex [split $line "\""] 1]]
set meaning [join [lrange [split $line "\""] 2 end]]
} else {
set found [lindex [split $line] 0]
set meaning [join [lrange [split $line] 1 end]]
}
lappend res $found
lappend res $meaning
return $res
}
proc dic:add {author word def} {
#Both word and def are lists when we get em.
global dictionary
set dictionary(changed) 1
set word [split $word]
if {[llength $word]>1} { set word "\"[join $word]\"" } else { set word [join $word] }
set def $def
set time [strftime %m-%d-%Y@%H:%M]
lappend dictionary(db) "$author $time $word $def"
}
Disregard my previous post. It would seem that the {} around words with special characters only comes when you remove a definition from the dictionary.
bind pub $dictionary(delflag) $dictionary(deltrigger) dic:pub:del
proc dic:pub:del {nick uhost handle chan line} {
global dictionary
if {$dictionary(dicmchanonly)==1 && [lsearch -exact [channel info $chan] +dicm]==-1} { return 0 }
if {[dic:check:flood $handle]} { return 0 }
if {[string range $line 0 0]=="\""} {
set found [join [lindex [split $line "\""] 1]]
set id [join [lindex [split $line "\""] 2]]
} else {
set found [join [lindex $line 0]]
set id [join [lindex $line 1]]
}
#check if id is a integer.
dic:del $found $id
putlog "$nick@$chan $dictionary(deltrigger) $line"
if {$dictionary(quiret) == 0 && [dic:ishub $chan]} {
if {$dictionary(where)==1} { putserv "PRIVMSG $chan :Deleted $found \[$id\]" }
if {$dictionary(where)==2} { putserv "NOTICE $nick :Deleted $found \[$id\]" }
}
}
proc dic:del {word id} {
#Input : word and id, if id=0 delete all def for that word.
#returns nothing
global dictionary
set dictionary(changed) 1
set word [join $word]
set bgdb $dictionary(db)
if {![info exists dictionary(db)]} { rehash ; return 0 }
unset dictionary(db)
set oid 0
foreach line $bgdb {
set line [split $line]
set found [lindex $line 2]
if {[string equal -nocase $found $word]} {
incr oid
if {$oid==$id || $id==0} { continue }
}
#We should only get here if the word is not matched or it is not the number we want.
lappend dictionary(db) $line
}
}
Every time someone removes a definition from the db it adds another pair of {} around words with special characters.
well, if the script's correctness is what bothers you, contacting the author is probably your best option; if you just need to get rid of that glitch, applying what I suggested is more than enough