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.

devoice on ban doesnt devoice {somenick}

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

devoice on ban doesnt devoice {somenick}

Post by simo »

i have this odd issue with this code it seems to devoice on ban almost all nicks that match the banmask exept if the nick is a nick with {} like {somenick} {nick2} and such im puzzled as to why

Code: Select all

bind mode - "* +b" devoice:onban

proc devoice:onban {nick uhost hand chan mc ban} {
   if {![botisop $chan]} { return }
    set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
    if { [string first ":" $ban] != -1 } { set ban [lindex [split $ban ":"] 1] }
   foreach n [chanlist $chan] {
     if {![matchaddr $ban $n![getchanhost $n $chan]]} { continue }
        if {![botisop $chan] || [isop $n $chan] || [ishalfop $n $chan] || [matchattr [nick2hand $n] fnmo|fnmo $chan] || [isbotnick $n]} { pushmode $chan -b $ban ; continue }
          if {[isvoice $n $chan]} { pushmode $chan -v $n }
   }
}

s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

nicks with {} [] seem to give lot of issues with many tcls scripts i noticed
i wonder if there is a general rule wich can be aplied to avoid all this
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It's been a while, so lets see how much I've actually forgotten...

As for brackets and braces in general, the most common issues I've come across over the years, is when scripters don't keep track of when they're operating on a string or a list. This is usually the case when I find search-and-replace snippets looking for those characters.
So only use list-operators (lindex, lrange, etc) on what you know to be a list.

The second most common one, is scripters sending unvalidated strings to expr/eval.

That said, I can't see any of those issues in the posted code.
You do have a search-and-replace snippet escaping backslash and opening-bracket in the banmask, which I belive is not needed (since banmasks use simple glob-style matching, not regular expressions). But unless the banmask includes those characters, that shouldn't be an issue.
Also curious why you split your banmask on ":"...

Think you could post some examples of banmasks and nicks that are not working properly?
NML_375
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks for your reply nml375

the reason for using :
if { [string first ":" $ban] != -1 } { set ban [lindex [split $ban ":"] 1] }
is to get the banmask from like muteban or other extended bans like:

+b m:nick!ident@host
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

examples of nicks it doesnt get the banmask for to set a devoice is nicks like

[nick]

{nick}
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i also noticed the built in ban-time setting doesnt unban banmasks like
{nick}!*@* as well
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i welcome any help to deal with nicks that have {}[] in them as they seem to cause alot of problems with tcls
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I was hoping for some actual samples that failed to execute properly.

However, if the banmask would contain { or [, your character substitution would certainly interfere with mask matching...

matchaddr does not support backslash escaping, so adding those would insert characters in the mask that will not match user's nick!user@host...

So, remove this line for starters:

Code: Select all

set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
NML_375
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i already tried both with and without that line both with same results
and i gave examples of banmasks let me give again


+b {nick}!*@*
+b [nick]!*@*
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Once again, I was not asking for examples, but actual samples that failed.

That said, I just fired up a 1.9.2 bot and did a few tests in console...

Code: Select all

.tcl set goodmask {[nick]!*@*}
Tcl: [nick]!*@*
.tcl set badmask [string map {"\\" "\\\\" "\[" "\\["} $goodmask]
Tcl: \[nick]!*@*
.tcl set uhost {[nick]!user@host}
Tcl: [nick]!user@host
.tcl matchaddr $goodmask $uhost
Tcl: 1
.tcl matchaddr $badmask $uhost
Tcl: 0
So, with the examples you posted, matching works just fine - as long as you don't start injecting random characters...

To ease with figuring out what is going wrong, we need actual samples. I would also recommend using putlog to print information such as what is the actual mask and nick!user@host used; or if the bot does not believe the user is voiced, etc...
NML_375
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

hm yes ive tested again and for some reason it seems fine now i cant grasp it ill monitor it some more and report back thanks again nml375 much apreciated
Post Reply