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.

Braces, brackets or backslash in the nicknames

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Braces, brackets or backslash in the nicknames

Post by juanamores »

I make a new post because the issue is to solve a portion of code that have been solved in other post.

In this TCL, for some reason the author decided to clean than nicks, the characters '{} [] \\'

For this purpose he used this process:

Code: Select all

proc charfilter {x {y ""} } {
  for {set i 0} {$i < [string length $x]} {incr i} {
    switch -- [string index $x $i] {
      "\"" {append y "\\\""}
      "\\" {append y "\\\\"}
      "\[" {append y "\\\["}
      "\]" {append y "\\\]"}
      "\}" {append y "\\\}"}
      "\{" {append y "\\\{"}
      default {append y [string index $x $i]}
    }
  }
  return $y
} 
When we add a nick with !addison command, the nick is added differently (if it contains braces, brackets or backslash).
Example.
<oper> !addison {fosforito}
<bot> Done. Successfully added \{fosforito\}.
Then when I want to remove that nick, bot tells me that is not found in the database.
<oper> !delison {fosforito}
<bot> Nickname fosforito not found in the database!
And if I try to remove the nick, the same way the bot added,the bot tells me that eliminated him, but in reality it does not eliminate the nick follows the archive database.
<oper> !delison \{fosforito\}
<bot> Nickname {fosforito} erased from the database!
<oper>!list
<bot>Added in the database: \{fosforito\}
I had a hard time understanding how this code, it may be because of my lack of experience.
Anyway, I could solve the other characters such as hyphens (-_-), but I could with whom I have discussed them.

Code: Select all

regsub -all "$who" $nicknames "" nicknames
Anyone is encouraged to analyze the code and see if you can find a solution?

EDIT: Solved! see this post.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply