View previous topic :: View next topic |
Author |
Message |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Wed Aug 10, 2022 12:10 pm Post subject: clear bans set by certain chanop |
|
|
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 :
to remove all channel bans
or
Quote: | !cb someopnick someopnick1 someopnick3 |
to only remove channel bans set by someopnick someopnick1 someopnick3
Code: |
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."
}
}
} |
|
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 831 Location: Tennessee, USA
|
Posted: Wed Aug 10, 2022 9:06 pm Post subject: Show your raw 367 reply... |
|
|
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. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Thu Aug 11, 2022 1:29 am Post subject: |
|
|
thanks for the response SpiKe^^
output of raw 367 is :
Quote: | irc.blah.com 367 Simo #channel *!*@cloaked-25lhta.contaboserver.net Hawk :1659848122 |
in the raw i also tried
Code: | 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 |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 831 Location: Tennessee, USA
|
Posted: Thu Aug 11, 2022 6:18 pm Post subject: |
|
|
Try this...
Code: |
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
}
}
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Thu Aug 11, 2022 7:12 pm Post subject: |
|
|
Thanks SpiKe^^ i loaded the code and tested it and it doesnt seem to react and am not gettin any error |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 831 Location: Tennessee, USA
|
Posted: Thu Aug 11, 2022 8:16 pm Post subject: |
|
|
that code seems fine to me _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Thu Aug 11, 2022 9:49 pm Post subject: |
|
|
tested again with all other scripts unloaded seems to work fine thanks SpiKe^^ |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Thu Aug 11, 2022 9:59 pm Post subject: |
|
|
tested again and for some reason if i use a non existing nick it still removes all bans like
while removing all bans should only be done with !cb |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Fri Aug 12, 2022 3:14 am Post subject: |
|
|
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:
Quote: | lair.nl.eu.dal.net 367 Cappuccino #channel *!*@DALnet-kx6.971.66.73.IP Cappuccino!~IRC@saffouane.powered.by.lunarbnc.net 1660288035 |
|
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Fri Aug 12, 2022 3:30 am Post subject: |
|
|
tried this and it seems to work not sure if i done it proper tho:
Quote: | lassign [split $text] bot chan mask setter
set setter [string tolower [lindex [split $setter !] 0]]
|
|
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 831 Location: Tennessee, USA
|
Posted: Fri Aug 12, 2022 10:36 am Post subject: |
|
|
Yup, the script ends up being quite network/server specific. Quote: | According to the list I use, the replies can be very different... <setter>, <time left> and <reason> are additions used by various servers. |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1054
|
Posted: Fri Aug 12, 2022 3:40 pm Post subject: |
|
|
Thanks SpiKe^^ |
|
Back to top |
|
 |
|