egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help: nick filter

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
[Lt]im
Voice


Joined: 09 Mar 2006
Posts: 17
Location: Kaunas - Lithuania

PostPosted: Thu Aug 24, 2006 5:08 pm    Post subject: Help: nick filter Reply with quote

Hello, i have this proccess:
Code:
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
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Aug 24, 2006 5:35 pm    Post subject: Reply with quote

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:
set victime [lindex [split $rest] 0]

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


Most likely, that'll take care of atleast some issues with usernames containing [] aswell..
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
[Lt]im
Voice


Joined: 09 Mar 2006
Posts: 17
Location: Kaunas - Lithuania

PostPosted: Thu Aug 24, 2006 6:05 pm    Post subject: Reply with quote

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. Rolling Eyes
_________________
[Lt]im
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Thu Aug 24, 2006 8:29 pm    Post subject: Reply with quote

[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. Rolling Eyes

You were given a "nick filter":
Code:
set victime [lindex [split $rest] 0]

or..
Code:
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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber