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 

ban enforce doesnt stack kicks

 
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: 941

PostPosted: Mon Jan 10, 2022 10:25 am    Post subject: ban enforce doesnt stack kicks Reply with quote

i took this code caesar wrote from another post to enforce bans to kick in stack
only to find it doesnt seem to stack it sends all found banned nicks to be kicked seperate

Code:

namespace eval enforceBans {

   set enforce(max) "4"

   set enforce(reason) "Ban %ban set in %from matches your host. You are banned!"
 
   bind mode - "% +b" [namespace current]::enforce

   proc enforce {nick uhost hand chan mc ban} {
      variable enforce
      set reason [string map [list "%from" $chan "%ban" $ban "%who" $nick] $enforce(reason)]
      if {![botisop $chan]} { return 0 }
      set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
       if {[matchstr "*@*mibbit*" "$ban"]} { return 0 }
       if {[string match -nocase $ban $::botname]} { return }
         foreach n [chanlist $chan] {
            if {![matchaddr $ban $n![getchanhost $n $chan]]} continue
            if {[isop $n $chan] || [ishalfop $n $chan] || [matchattr [nick2hand $n] "fnmo|fnmo" $chan]} continue
          if {[onchan $n $chan]} { lappend kickList($chan) $n }
         }
      if {[llength $kickList($chan)]  > 2} { return }
         if {[info exists kickList($chan)]} {
         set kickList($chan) [lsort -dictionary $kickList($chan)]
            set len [llength $kickList($chan)]
            while {$len > 0} {
               if {$len > $enforce(max)} {
                  set users [join [lrange $kickList($chan) 0 [expr {$enforce(max) - 1}]] ,]
                  set kickList($chan) [lrange $kickList($chan) $enforce(max) end]
                  incr len -$enforce(max)
               } else {
                  set users [join $kickList($chan) ,]
                  set len 0
               }
             after [expr {2*1000*1}] [list putnow "kick $chan $users $reason"]
            }
         }
      }
   }
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jan 10, 2022 10:37 am    Post subject: Reply with quote

i cant figure why it doesnt stack the nicks to kick
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jan 10, 2022 10:52 am    Post subject: Reply with quote

Short question: does your server accept multiple kicks in a single line ?
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jan 10, 2022 11:10 am    Post subject: Reply with quote

yes dalnet does 4 and inspircd 20
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jan 10, 2022 1:10 pm    Post subject: Reply with quote

i tried with this:

Code:

namespace eval enforceBans {

   set enforce(max) "4"

   set enforce(reason) "Ban %ban set in %from matches your host. You are banned!"
 
   bind mode - "% +b" [namespace current]::enforce

   proc enforce {nick uhost hand chan mc ban} {
      variable enforce
      variable kickList
      set reason [string map [list "%from" $chan "%ban" $ban "%who" $nick] $enforce(reason)]
      if {![botisop $chan]} { return 0 }
      set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
       if {[matchstr "*@*mibbit*" "$ban"]} { return 0 }
       if {[string match -nocase $ban $::botname]} { return }
         foreach n [chanlist $chan] {
            if {![matchaddr $ban $n![getchanhost $n $chan]]} continue
            if {[isop $n $chan] || [ishalfop $n $chan] || [matchattr [nick2hand $n] "fnmo|fnmo" $chan]} continue
          if {[onchan $n $chan]} { lappend kickList($chan) $n }
         }

         if {[info exists kickList($chan)]} {
         set kickList($chan) [lsort -dictionary $kickList($chan)]
            set len [llength $kickList($chan)]
            while {$len > 0} {
               if {$len > $enforce(max)} {
                  set users [join [lrange $kickList($chan) 0 [expr {$enforce(max) - 1}]] ,]
                  set kickList($chan) [lrange $kickList($chan) $enforce(max) end]
                  incr len -$enforce(max)
               } else {
                  set users [join $kickList($chan) ,]
                  set len 0
               }
             after [expr {2*1000*1}] [list putnow "kick $chan $users $reason"]
            }
         }
      }
   }



but it doesnt get rid of the nicks that are already kicked it keeps adding the same nicks
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Tue Jan 11, 2022 1:52 am    Post subject: Reply with quote

Code:

namespace eval enforceBans {
   variable enforce  ;  variable kickList

   set enforce(max) "4"

   #set enforce(reason_single) "Ban %ban set in %from matches your host. You are banned!"
   set enforce(reason_multi) "A new ban in %from matches your host. You are banned!"

   bind mode - "% +b" [namespace current]::enforce

   proc enforce {nick uhost hand chan mc ban} {
      variable kickList
      if {[matchaddr $ban $::botname]} { return 0 }
      if {[matchstr "*@*mibbit*" $ban]} { return 0 }

      foreach n [chanlist $chan] {
         if {![matchaddr $ban $n![getchanhost $n $chan]]} { continue }
         if {[isop $n $chan] || [ishalfop $n $chan]} { continue }
         if {[matchattr [nick2hand $n] "fnmo|fnmo" $chan]} { continue }
         lappend klist $n
      }
      if {![info exists klist]} { return 0 }

      if {![info exists kickList($chan)]} {
         set kickList($chan) $klist
         after 2000 [list "[namespace current]::enforce:kick" $chan]

      } else {  lappend kickList($chan) {*}$klist  }

      return 0
   }

   proc enforce:kick {chan} {
      variable enforce
      variable kickList
      if {![botisop $chan] || ![info exists kickList($chan)]} {
         array unset kickList $chan
         return 0
      }

      set knicks [lsort -unique -dictionary $kickList($chan)]
      unset kickList($chan)

      set max $enforce(max)
      set reason [string map [list %from $chan] $enforce(reason_multi)]

      while {[set len [llength $knicks]] > 0} {
        if {$len > $max} {
          set nicks [join [lrange $knicks 0 [expr {$max - 1}]] ","]
          set knicks [lrange $knicks $max end]
        } else {
          set nicks [join $knicks ","]
          set knicks ""
        }
        putquick "KICK $chan $nicks :$reason"
      }
      return 0
   }

}


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.


Last edited by SpiKe^^ on Tue Jan 11, 2022 2:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jan 11, 2022 8:55 am    Post subject: Reply with quote

excellent thanks Spike^^ that seems to do it
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