egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

clear bans set by certain chanop

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 10, 2022 12:10 pm    Post subject: clear bans set by certain chanop Reply with quote

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 :

Quote:
!cb

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 809
Location: Tennessee, USA

PostPosted: Wed Aug 10, 2022 9:06 pm    Post subject: Show your raw 367 reply... Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Thu Aug 11, 2022 1:29 am    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 809
Location: Tennessee, USA

PostPosted: Thu Aug 11, 2022 6:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Thu Aug 11, 2022 7:12 pm    Post subject: Reply with quote

Thanks SpiKe^^ i loaded the code and tested it and it doesnt seem to react and am not gettin any error
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 809
Location: Tennessee, USA

PostPosted: Thu Aug 11, 2022 8:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Thu Aug 11, 2022 9:49 pm    Post subject: Reply with quote

tested again with all other scripts unloaded seems to work fine thanks SpiKe^^
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Thu Aug 11, 2022 9:59 pm    Post subject: Reply with quote

tested again and for some reason if i use a non existing nick it still removes all bans like

Quote:
!cb kjshjfuye


while removing all bans should only be done with !cb
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Fri Aug 12, 2022 3:14 am    Post subject: Reply with quote

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
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Fri Aug 12, 2022 3:30 am    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 809
Location: Tennessee, USA

PostPosted: Fri Aug 12, 2022 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Fri Aug 12, 2022 3:40 pm    Post subject: Reply with quote

Thanks SpiKe^^
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber