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.

Help: nick filter

Help for those learning Tcl or writing their own scripts.
Post Reply
[
[Lt]im
Voice
Posts: 17
Joined: Thu Mar 09, 2006 4:20 pm
Location: Kaunas - Lithuania

Help: nick filter

Post by [Lt]im »

Hello, i have this proccess:

Code: Select all

proc pwf_addadmin {nick uhost hand channel rest} {
  global pwf_pickupchan pwf_qauthnick pwf_qauthnick_timers pwf_qauth
   
  set channel [string tolower $channel]
  if { $channel == $pwf_pickupchan } {
    set victime [lindex $rest 0]
    if { [matchattr $hand H] } {
      if [matchattr $hand m|m $channel] {
        if [onchan $victime $channel] {
          if {($pwf_qauth=="Q")||($pwf_qauth=="T")} {
            set pwf_qauthnick_timers($victime) [utimer 20 "set pwf_qauthnick($victime) 0"]
            trace variable pwf_qauthnick($victime) w pwf_addadmincheck
            putserv "WHOIS $victime"
          }
          set victhand [nick2hand $victime]
          if [string compare $victhand "*"] {
            if [matchattr $victhand GL|GL $channel] {
              putserv "NOTICE $nick :[pwf_txt right1]"
            } else {
              chattr $victhand +|GL $channel
              putserv "NOTICE $nick :[pwf_txt right2] $victime"
              putserv "NOTICE $victime :[pwf_txt right3] $channel [pwf_txt right4a]"
              return 1
            }
          } else {
            adduser $victime [maskhost [getchanhost $victime $channel]]
            chattr [nick2hand $victime] +|GL $channel
            putserv "NOTICE $nick :[pwf_txt right2] $victime"
            putserv "NOTICE $victime :[pwf_txt right3] $channel [pwf_txt right4b]"
            return 1
          }
        } else {
          putserv "NOTICE $nick :[pwf_txt right5]"
        }
      } else {
        putserv "NOTICE $nick :[pwf_txt right6]"
      }
    } else {
      putserv "NOTICE $nick :[pwf_txt noauth]"
    }
  }
}
Can anyone help to edit this script, that eggdrop would not let to add new admin if he has "[" "]" in his nick?
[Lt]im
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'd use some regexp check for that..

One thing I did notice tho, in the beginning of your code, you are using lindex improperly. That is, you're using it on a string. To make matters even worse, it's a string supplied by a person..

what you'll have to do is something like this:

Code: Select all

set victime [lindex [split $rest] 0]
Instead of this:

Code: Select all

set victime [lindex $rest 0]
Most likely, that'll take care of atleast some issues with usernames containing [] aswell..
NML_375
[
[Lt]im
Voice
Posts: 17
Joined: Thu Mar 09, 2006 4:20 pm
Location: Kaunas - Lithuania

Post by [Lt]im »

Yeah,... but i really need "nick filter", that bot wount let to add new admin if he has "[ ]" in his nick, because after game, bot writes [admin] to pwf_stats like this - {[admin]}, and when gstat command is used, bot craches while trying to read {[admin]} from pwf_stats. :roll:
[Lt]im
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

[Lt]im wrote:Yeah,... but i really need "nick filter", that bot wount let to add new admin if he has "[ ]" in his nick, because after game, bot writes [admin] to pwf_stats like this - {[admin]}, and when gstat command is used, bot craches while trying to read {[admin]} from pwf_stats. :roll:
You were given a "nick filter":

Code: Select all

set victime [lindex [split $rest] 0]
or..

Code: Select all

set victime [lindex [split [string trim $rest]] 0]
Edit your code accordingly and rehash the the bot.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Post Reply