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.

Kicking nicknames with brackets in them

Old posts that have not been replied to for several years.
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

the nickname is only stored in nickhost, and there are no processes interfering with it.
The best way to start learning is to start helping.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Kicking nicknames with brackets in them

Post by user »

user wrote:Don't 'join' the string returned by 'lindex' and everything should be fine :)
Have you ever read "The Manual"?
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Just to clear it up, as it may pose to some a bit of confusion...

We join the "lrange" result (the reason) because lrange returns a list of elements, and the list needs to be converted back to string...

You do NOT join the result of "lindex" (in this case, anyways), as it returns a single element, which happens to already be a string.

Usually, you will only need to use join on a lindex operation when the list you are working with is a list of lists (that is, sub-lists contained within a list).
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

alright, thanks a lot :)

It's working now, but now im having the same problem with my ban command... I just don't see it.. :(

Code: Select all

proc academy:ban {nick host handle chan text} { 
  global botnick guardmethod 

  if {(![authed $handle]) || ![string equal -nocase $chan "#jedi-academy"]} { return 0 } 

  set userlevel [level $handle]
  set nickhost [lindex [split $text] 0]
  set time [lindex $text 1]
  set reason [join [lrange [split $text] 2 end]]

  if {$userlevel == "Knight" || $nickhost == ""} {return 0}
  if {$time == "perm"} { set time "0" }


  if {[onchan $nickhost $chan]} { 
  	if {[string match "*.users.quakenet.org" [getchanhost $nickhost $chan]]} { 
 		set banmask "*!*@[lindex [split [getchanhost $nickhost $chan] @] 1]"
   	} else {
      	set banmask "*!*[string trimleft [maskhost [getchanhost $nickhost $chan]] *!]"
 	}
  }

  if {$reason == ""} {
  	set reason "Banned via JAbot by $nick. No reason specified."
  }

  if {[nick2hand $nickhost] != "*"} {
  	if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} { 
  		return 0 
	} 
  }

  if {[botisop $chan]} {
  	if {[onchan $nickhost $chan]} {
    	if {![string equal -nocase [maskhost [getchanhost $botnick]] [maskhost $nickhost]] && ![string equal -nocase $botnick $nickhost]} { 
        	if {$time == "0"} {
           		newchanban $chan $banmask [nick2hand $nick] "$reason (permanent)" $time
	        	} else {
           			newchanban $chan $banmask [nick2hand $nick] "$reason ($time minutes)" $time
	            }
	            webbanlist_createhtml
        } else {
	      	putserv "$guardmethod $nick : $nick whats wrong with you?"
          }
	} else {
    	if {![string equal -nocase [maskhost [getchanhost $botnick]] $nickhost] && ![string equal -nocase $botnick $nickhost]} { 
			newchanban $chan $nickhost $handle "$reason" $time
    	  	putserv "$guardmethod $nick : $nick, \002$nickhost\002 has been added to the $chan banlist, and will be banned when he enters."
	    	webbanlist_createhtml
        } else {
	      	putserv "$guardmethod $nick : $nick, quit messing around."
        }            
    }
  } else {
    	putserv "$guardmethod $nick  : $botnick is not opped on $chan"
    } 
}
The best way to start learning is to start helping.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Haven't you learned anything by now? In if {$foo == "foo"} { eyther do an string tolower/ toupper to the $foo or use the "string equal -nocase" to do that for you cos FOO (Foo, fOo, etc.) is not equal with "foo"..

Code: Select all

if {![string equal -nocase [maskhost [getchanhost $botnick]] $nickhost] .. etc.
no way, better use the $botname to get it's nick!ident@host that that and cmpare it with "string match -nocase".

Code: Select all

if {[string match -nocase $nickhost $botname]} { # etc. }
Your code is so mixed up.. confused me a a lil bit..

Code: Select all

if {![string equal -nocase [maskhost [getchanhost $botnick]] [maskhost $nickhost]] && ![string equal -nocase $botnick $nickhost]} { 
no, better use "isbotnick" instead of "![string equal -nocase $botnick $nickhost]" if you are comparing the two nicks or something similar.

Code: Select all

if {[nick2hand $nickhost] != "*"} { 
  if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} { 
    return 0 
  } 
} 
Either store the [nick2hand $nickhost] in to an variable and don't call it twice or go directly to:

Code: Select all

if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} { 
  return 0 
}
cos as far as I see there is no need of the first check.

Code: Select all

if {$time == "perm"} { set time "0" } 
should be:

Code: Select all

if {[string tolower $time] == "perm"} { set time 0 }
Once the game is over, the king and the pawn go back in the same box.
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

I have looked over it time and time again, and i just dont see it. I already fixed those errors.

Code: Select all

proc academy:ban {nick host handle chan text} { 
  global botnick guardmethod botname

  if {(![authed $handle]) || ![string equal -nocase $chan "#jedi-academy"]} { return 0 } 

  set userlevel [level $handle]
  set nickhost [lindex [split $text] 0]
  set time [lindex $text 1]
  set reason [join [lrange [split $text] 2 end]]

  if {$userlevel == "Knight" || $nickhost == ""} {return 0}
  if {[string tolower $time] == "perm"} { set time 0 } 


  if {[onchan $nickhost $chan]} { 
  	if {[string match "*.users.quakenet.org" [getchanhost $nickhost $chan]]} { 
 		set banmask "*!*@[join [lindex [split [getchanhost $nickhost $chan] @] 1]]"
   	} else {
      	set banmask "*!*[string trimleft [maskhost [getchanhost $nickhost $chan]] *!]"
 	}
  }

  if {$reason == ""} {
  	set reason "Banned via JAbot by $nick. No reason specified."
  }

if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} {
  return 0
} 

  if {[botisop $chan]} {
  	if {[onchan $nickhost $chan]} {
         if {![string match -nocase $nickhost $botname] || ![isbotnick $nickhost]} { 
        	if {$time == "0"} {
           		newchanban $chan $banmask [nick2hand $nick] "$reason (permanent)" $time
	        	} else {
           			newchanban $chan $banmask [nick2hand $nick] "$reason ($time minutes)" $time
	            }
	            webbanlist_createhtml
        } else {
	      	putserv "$guardmethod $nick : $nick whats wrong with you?"
          }
	} else {
    	if {![string equal -nocase [maskhost [getchanhost $botnick]] $nickhost] && ![string equal -nocase $botnick $nickhost]} { 
			newchanban $chan $nickhost $handle "$reason" $time
    	  	putserv "$guardmethod $nick : $nick, \002$nickhost\002 has been added to the $chan banlist, and will be banned when he enters."
	    	webbanlist_createhtml
        } else {
	      	putserv "$guardmethod $nick : $nick, quit messing around."
        }            
    }
  } else {
    	putserv "$guardmethod $nick  : $botnick is not opped on $chan"
    } 
}
The best way to start learning is to start helping.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

set time [lindex $text 1]? :P
Have you ever read "The Manual"?
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Post by Aron »

alright, i feel like a retard now.

Thanks a lot man, it solved the problem. ;)
The best way to start learning is to start helping.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Your welcome. :mrgreen:
Once the game is over, the king and the pawn go back in the same box.
Locked