View previous topic :: View next topic |
Author |
Message |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 208 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Feb 10, 2018 9:06 pm Post subject: recognize special characters in nicknames |
|
|
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: | 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"
}
} } |
_________________
thanks to that they help, that others learn  |
|
Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 208 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Feb 10, 2018 9:12 pm Post subject: Re: recognize special characters in nicknames |
|
|
Try to use the same resource but in the second example it did not work for me:
Code: | 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 _________________
thanks to that they help, that others learn  |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3690 Location: Mint Factory
|
Posted: Fri Feb 16, 2018 3:23 am Post subject: |
|
|
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.
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. |
|
Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 208 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Fri Feb 23, 2018 3:51 pm Post subject: |
|
|
it works but not very well...
recognizes normal nicknames
but nicknames with special characters do not recognize them example : {N}ick
Code: | 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: | [15:47:40] Tcl error [op]: list element in braces followed by "ick" instead of space |
_________________
thanks to that they help, that others learn  |
|
Back to top |
|
 |
|