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.

enforcebans kicker with timer

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

enforcebans kicker with timer

Post by simo »

i was trying out this enforce bans code

and was wondering how to edit it to have banned users kicked out but with a timer
and to have it check afterwards if the banned nick is actually still on channel and perhaps if multiple nicks have been banned within short period to send it with just a single timer to prevent a bunch of timers do to the same job on multiple nicks

Code: Select all

bind mode - "* +b" enforcebansq
 
proc enforcebansq {nick uhost hand chan mc ban} {
  if {![string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $::botname]} {
    foreach n [chanlist $chan] {
      if {[string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $n![getchanhost $n $chan]]} {
       if {![isop $n $chan] && ![ishalfop $n $chan] && ![matchattr $hand o|o $chan]} { after [expr {5*1000*1}] [list checkenforceq $chan $n] }
      }
    }
  } else { 
       return 
  }
}

   proc checkenforceq {chan nick} {
   if {[onchan $nick $chan]} { 
		putserv "kick $chan $nick :PLease follow our rules terms and conditions of our network thank you for more info use: /rules"
    } else { return }
}
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

actually we use this :

Code: Select all

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"]
            }
         }
      }
   }
i was wondering how to send the stored nicks to be kicked in this line
after [expr {2*1000*1}] [list putnow "kick $chan $users $reason"]
to perhaps check if they are still online before kicking to make sure its not kicking out nicks that already have been kicked out or left channel
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh i actually found the pasted code odly doesnt stack the kicks
Post Reply