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.

recognize special characters in nicknames

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

recognize special characters in nicknames

Post by Arnold_X-P »

I was trying out this little tcl
to recognize special characters in nicknames works but does not recognize all the special variants in nicknames
example : [L|I|T|0] [-Nick-] {N}ick [-Nick-]

Code: Select all

bind PUB o !op procname

proc procname {nick uhost hand chan text} {
  set target [string trim $text]
  if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $target]} {
  if {$target == ""} {
  putserv "mode $chan +o $target"
  } else {
  putserv "PRIVMSG $chan :$nick It's not in $chan"
  }
} }
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Re: recognize special characters in nicknames

Post by Arnold_X-P »

Try to use the same resource but in the second example it did not work for me:

Code: Select all

bind PUB o !op op

proc op {nick host hand chan text} {
global flagaccess
 if {![matchattr $hand $flagaccess $chan]} { 
if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $target]} {
  if {$target == ""} { 
set target [lindex $text 0]
set target1 [lindex $text 1]
set target2 [lindex $text 2]
set target3 [lindex $text 3]
set target4 [lindex $text 4]
if {![botisop $chan]} {
puthelp "NOTICE $nick :I'm down I do not have @ in $chan"
}
if {$target == ""} {
 puthelp "MODE $chan +o $nick"
  }
 puthelp "MODE $chan +ooooo $target $target1 $target2 $target3 $target4"
 return 0
 }
error in partyline
[20:24:46] Tcl error [op]: list element in braces followed by "ick" instead of space
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What if the "text" contains only one name (or better said element)? What would you say it happens?

Don't know what that regexp is supposed to do but if $text has just one element (is a list of unknown number of elements at this time) then it will fail to grab index number 1, 2, 3 and obviously 4 thus failing with an error. My guess is that you didn't see it because of that regexp doing something and execution is halted there.

Safest option in my opinion would be a foreach loop over splitting that $text list cos it's not safe to trust your users input and based on how many of the "elements" need op, are on the channel and whatever other checks you want to add and then add them into another list that you just create then loop over it outside the first one to do the actual +o on each element you found in the first.

This has been discussed many times in the past so will let you figure out what code you actually need. :P

If you try something and get stuck then I will help you out.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

it works but not very well...
recognizes normal nicknames
but nicknames with special characters do not recognize them example : {N}ick

Code: Select all

bind PUB o !topme op

proc op {nick host hand chan text} {
global flagaccess
  foreach user [split $text] {
if {![botisop $chan]} {
puthelp "NOTICE $nick :I'm down I do not have @ in $chan"
}
if {$user == ""} {
 puthelp "MODE $chan +o $user"
  }
 puthelp "MODE $chan +ooooo $user $user $user $user $user"
 return 0
 } 
and error in partyline:

Code: Select all

[15:47:40] Tcl error [op]: list element in braces followed by "ick" instead of space 
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
Post Reply