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.

clear bans set by certain chanop

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

clear bans set by certain chanop

Post by simo »

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." 
      } 
   } 
}
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Show your raw 367 reply...

Post by SpiKe^^ »

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
.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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

      } 
   } 
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanks SpiKe^^ i loaded the code and tested it and it doesnt seem to react and am not gettin any error
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested again with all other scripts unloaded seems to work fine thanks SpiKe^^
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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:
lair.nl.eu.dal.net 367 Cappuccino #channel *!*@DALnet-kx6.971.66.73.IP Cappuccino!~IRC@saffouane.powered.by.lunarbnc.net 1660288035
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

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]]
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanks SpiKe^^
Post Reply