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.
Help for those learning Tcl or writing their own scripts.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Mar 15, 2022 6:08 am
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
CrazyCat
Revered One
Posts: 1305 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Mar 15, 2022 8:09 am
Use join to get a string rather than a list: split creates a list, lrange works on list. You want text.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Mar 15, 2022 9:15 am
thanks CC for your response but im kinda lost how to use it proper
would you have an examples ?
CrazyCat
Revered One
Posts: 1305 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Mar 15, 2022 10:15 am
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"
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Mar 15, 2022 12:25 pm
thanks CC both seem to work well , any reason why the second would be more proper ?