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.

pub modes command sets odd banmasks

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

pub modes command sets odd banmasks

Post by simo »

im using this code for a while and cant figure out why it sets weird banmasks
on certain nicks i was told on eggdrop support channel not to use split but even after consulting the docs i couldnt figure it out

this is the code :

Code: Select all

bind pubm n|n "#% +?*" pub:massmodez317
bind pubm n|n "#% -?*" pub:massmodez317

proc pub:massmodez317 {nick host hand chan text} {
   set modex [join [lindex [split $text] 0]]
  set restmodes [lrange [split $text] 1 end]
  if { [onchan [string map {+ "" - ""} $modex] $chan] } { return 0 }
   if { [llength [split $text]] == 2 } {
      putnow "MODE $chan $modex $restmodes"
   } else {  return 0  }
}
for example when i set a ban on a nick like [somenick] or {somenick} like this

+b [somenick]
+b {somenick}

it sets it as +b {{[somenick]}}
it sets it as +b {{{somenick}}}

i was told it has to do with the split that was used
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Use join to get a string rather than a list: split creates a list, lrange works on list. You want text.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks CC for your response but im kinda lost how to use it proper

would you have an examples ?
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Simple method:

Code: Select all

bind pubm n|n "#% +?*" pub:massmodez317
bind pubm n|n "#% -?*" pub:massmodez317

proc pub:massmodez317 {nick host hand chan text} {
   set modex [join [lindex [split $text] 0]]
  set restmodes [join [lrange [split $text] 1 end]]
  if { [onchan [string map {+ "" - ""} $modex] $chan] } { return 0 }
   if { [llength [split $text]] == 2 } {
      putnow "MODE $chan $modex $restmodes"
   } else {  return 0  }
} 
Better method:

Code: Select all

bind pubm n|n "#% +?*" pub:massmodez317
bind pubm n|n "#% -?*" pub:massmodez317

proc pub:massmodez317 {nick host hand chan text} {
   if {[llength [split $text]]!=2} { return 0}
   set modex [join [lindex [split $text] 0]]
   if { [onchan [string map {+ "" - ""} $modex] $chan] } { return 0 }
   set restmodes [join [lrange [split $text] 1 end]]
   putnow "MODE $chan $modex $restmodes"
} 
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks CC both seem to work well , any reason why the second would be more proper ?
Post Reply