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 » Wed Aug 10, 2022 12:10 pm
greetz gentz,
we used this code to clear all bans from channel banlist
and i was wondering about how to edit it to have it clear all bans if no chanop is provided or only clear bans set by certain chanops like for example :
!cb
to remove all channel bans
or
!cb someopnick someopnick1 someopnick3
to only remove channel bans set by someopnick someopnick1 someopnick3
Code: Select all
set clearbans(max) 6
bind pub n !cb clear:bans2021
proc clear:bans2021 {nick uhost hand chan text} {
global clearbans nickoutput
set chan [string tolower $chan]
set nickoutput [string tolower $nick]
if {![botisop $chan]} return
set clearbans($chan) {}
bind raw - 367 cb:bind:raw2021
bind raw - 368 cb:bind:raw2021
putnow "MODE $chan b"
}
proc cb:bind:raw2021 {from key text} {
global clearbans nickoutput
switch -- $key {
367 {
lassign [split $text] bot chan mask
set chan [string tolower $chan]
if {![info exists clearbans($chan)]} return
if {[lsearch $clearbans($chan) $mask] > -1} return
lappend clearbans($chan) $mask
}
368 {
lassign [split $text] bot chan
set chan [string tolower $chan]
if {![info exists clearbans($chan)]} return
unbind raw - 367 cb:bind:raw2021
unbind raw - 368 cb:bind:raw2021
set len [llength $clearbans($chan)]
set total 0
if {$len > 0} {
while {$len > 0} {
if {$len > $clearbans(max)} {
set mode [string repeat "b" $clearbans(max)]
set masks [join [lrange $clearbans($chan) 0 [expr {$clearbans(max) - 1}]]]
set clearbans($chan) [lrange $clearbans($chan) $clearbans(max) end]
incr len -$clearbans(max)
incr total $clearbans(max)
} else {
set mode [string repeat "b" $len]
set masks [join $clearbans($chan)]
incr total $len
set len 0
}
puthelp "MODE $chan -$mode $masks"
}
} else {
putserv "NOTICE $nickoutput :\00300,04 No bans to clear from [bold][yellow] $chan. [end]" ; return
}
puthelp "notice $nickoutput :Removed $total bans. $chan Ban list is cleared."
}
}
}
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Wed Aug 10, 2022 9:06 pm
Show your raw 367 reply...
According to the list I use, the replies can be very different... <setter>, <time left> and <reason> are additions used by various servers.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Thu Aug 11, 2022 1:29 am
thanks for the response SpiKe^^
output of raw 367 is :
irc.blah.com 367 Simo #channel *!*@cloaked-25lhta.contaboserver.net Hawk :1659848122
in the raw i also tried
Code: Select all
lassign [split $text] bot chan chanops
to get the chanops out of the raw (the one who set the ban) seems to work for the raw part now i need to find for the bind pub part and use in the raw event to compare
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Thu Aug 11, 2022 6:18 pm
Try this...
Code: Select all
set clearbans(max) 6
bind pub n !cb clear:bans2021
proc clear:bans2021 {nick uhost hand chan text} {
global clearbans nickoutput clearnicks
set clearnicks [split [string trim [string tolower $text]]]
set chan [string tolower $chan]
set nickoutput [string tolower $nick]
if {![botisop $chan]} return
set clearbans($chan) {}
bind raw - 367 cb:bind:raw2021
bind raw - 368 cb:bind:raw2021
putnow "MODE $chan b"
}
proc cb:bind:raw2021 {from key text} {
global clearbans nickoutput clearnicks
switch -- $key {
367 {
lassign [split $text] bot chan mask setter
set setter [string tolower $setter]
set chan [string tolower $chan]
if {![info exists clearbans($chan)]} return
if {[lsearch $clearbans($chan) $mask] > -1} return
if {![llength $clearnicks] || $setter in $clearnicks} {
lappend clearbans($chan) $mask
}
}
368 {
lassign [split $text] bot chan
set chan [string tolower $chan]
if {![info exists clearbans($chan)]} return
unbind raw - 367 cb:bind:raw2021
unbind raw - 368 cb:bind:raw2021
set len [llength $clearbans($chan)]
set total 0
if {$len > 0} {
while {$len > 0} {
if {$len > $clearbans(max)} {
set mode [string repeat "b" $clearbans(max)]
set masks [join [lrange $clearbans($chan) 0 [expr {$clearbans(max) - 1}]]]
set clearbans($chan) [lrange $clearbans($chan) $clearbans(max) end]
incr len -$clearbans(max)
incr total $clearbans(max)
} else {
set mode [string repeat "b" $len]
set masks [join $clearbans($chan)]
incr total $len
set len 0
}
puthelp "MODE $chan -$mode $masks"
}
if {![llength $clearnicks]} {
puthelp "notice $nickoutput :Removed $total bans. $chan Ban list is cleared."
} else {
puthelp "notice $nickoutput :Removed $total bans in $chan. Cleared all bans set by: [join $clearnicks]."
}
} else {
putserv "NOTICE $nickoutput :\00300,04 No bans to clear from [bold][yellow] $chan. [end]"
}
unset clearbans($chan) ; unset nickoutput clearnicks
}
}
}
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Thu Aug 11, 2022 7:12 pm
Thanks SpiKe^^ i loaded the code and tested it and it doesnt seem to react and am not gettin any error
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Thu Aug 11, 2022 8:16 pm
that code seems fine to me
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Thu Aug 11, 2022 9:49 pm
tested again with all other scripts unloaded seems to work fine thanks SpiKe^^
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Thu Aug 11, 2022 9:59 pm
tested again and for some reason if i use a non existing nick it still removes all bans like
!cb kjshjfuye
while removing all bans should only be done with !cb
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Fri Aug 12, 2022 3:14 am
did another 2 tests on my own testnet and on dalnet and on dalnet it doesnt seem to work after i consulted raw 367 on dalnet i found the issue:
this is the output for dalnet raw 367:
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Fri Aug 12, 2022 3:30 am
tried this and it seems to work not sure if i done it proper tho:
lassign [split $text] bot chan mask setter
set setter [string tolower [lindex [split $setter !] 0]]
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Fri Aug 12, 2022 10:36 am
Yup, the script ends up being quite network/server specific.
According to the list I use, the replies can be very different... <setter>, <time left> and <reason> are additions used by various servers.
simo
Revered One
Posts: 1107 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Fri Aug 12, 2022 3:40 pm
Thanks SpiKe^^