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.

Enforce Ban

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

Sorry Friends, but I haven't given try to the code you made, but just got it fixed what I had with help of some of my mate (KissMine on DALnet). Just pasting here for reference and it works all fine as I wanted. Thanks for the help :D

Code: Select all

bind mode - "* +b" enforcebans 

set enforce(max) "8" 
set enforce(kmsg) "Banned :ban: by :nick:" 

proc enforcebans {nick uhost hand chan mc ban} {
   global enforce
    if {![botisop $chan]} { return }
   set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
   if {[string match -nocase $ban $::botnick]} { return }
   set kickmsg "$enforce(kmsg)"
   regsub -all :ban: $kickmsg $ban kickmsg
   regsub -all :nick: $kickmsg $nick kickmsg
   set list ""
   foreach user [chanlist $chan] {
      if {[matchattr [nick2hand $user] f $chan]} { continue }
      if {[string match -nocase $ban $user![getchanhost $user $chan]]} {
         lappend list $user
      }
   }
   if {[string match [llength $list] 0]} { return }
   if {[llength $list] > $enforce(max)} {
      putserv "MODE $chan -ob $nick $ban"
   } else {
      if {[llength $list] <= "3"} {
         putserv "KICK $chan [join $list ,] :$kickmsg"
      } else {
         set nlist ""
         foreach x $list {
            lappend nlist $x
            if {[llength $nlist] == "3"} {
               putserv "KICK $chan [join $nlist ,] :$kickmsg"
               set nlist ""
            }
         }
         if {[llength $nlist] != ""} {
            putserv "KICK $chan [join $nlist ,] :$kickmsg"
            set nlist ""
         }
      }
   }
}

putlog "Enforcebans loaded."
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

.

Post by sdays »

This is like something im looking for, but can someone edit it where it
can load from a txt file thanks :D

Code: Select all

bind mode - "* +b" enforcebans

set enforce(max) "8"
set enforce(kmsg) ""

proc enforcebans {nick uhost hand chan mc ban} {
   global enforce
    if {![botisop $chan]} { return }
   set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
   if {[string match -nocase $ban $::botnick]} { return }
   set kickmsg "$enforce(kmsg)"
   regsub -all :ban: $kickmsg $ban kickmsg
   regsub -all :nick: $kickmsg $nick kickmsg
   set list ""
   foreach user [chanlist $chan] {
      if {[matchattr [nick2hand $user] f $chan]} { continue }
      if {[string match -nocase $ban $user![getchanhost $user $chan]]} {
         lappend list $user
      }
   }
   if {[string match [llength $list] 0]} { return }
   if {[llength $list] > $enforce(max)} {
      putserv "MODE $chan -ob $nick $ban"
   } else {
      if {[llength $list] <= "3"} {
         putserv "KICK $chan [join $list ,] :$kickmsg"
      } else {
         set nlist ""
         foreach x $list {
            lappend nlist $x
            if {[llength $nlist] == "3"} {
               putserv "KICK $chan [join $nlist ,] :$kickmsg"
               set nlist ""
            }
         }
         if {[llength $nlist] != ""} {
            putserv "KICK $chan [join $nlist ,] :$kickmsg"
            set nlist ""
         }
      }
   }
}

putlog "Enforcebans loaded."
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Why do you even use that version?

This is a much cleaner version.

Code: Select all

bind mode - "* +b" enforcebans

set enforce(max) "8"
set enforce(kmsg) "Banned :ban: by :nick:"

proc enforcebans {nick uhost hand chan mc ban} {
  global enforce
  if {[botisop $chan]} {
  
    set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
    set reason [string map [list ":ban:" "$ban" ":nick" "$nick"] $enforce(kmsg)]
    
    set list [list]
    foreach user [chanlist $chan] {
      if {[isbotnick $user]} {
        continue
      } elseif {[matchattr [nick2hand $user] f|f $chan]} {
        continue
      } elseif {[string match -nocase $ban $user![getchanhost $user $chan]]} {
        lappend list $user
      }
    }
    
    if {[set llist [llength $list]] > $enforce(max)} {
      putserv "MODE $chan -ob $nick $ban"
    } else {
      for {set i 0;set temp [list];set j 0} {$i <= $llist} {incr i} {
        if {$j == 3 || $i == $llist} {
          if {$j > 0} {
            putserv "KICK $chan [join $temp ,] :$reason"
            set temp [list]
            set j 0
          }
        }
        lappend temp [lindex $list $i]
        incr j
      }
    } 
  }
}
Now if you want it to use random kickmessages from a file, use the snippet I gave you in a different topic (which begs the question why you aren't using it?).

Code: Select all

proc getrandomreason {} {
  set file [open "YOURFILE" r]
  set data [split [read $file] \n]
  close $file

  return [lindex $data [rand [llength $data]]]
}
If you want it to use a random message for every kick, simply change $reason to [getrandomreason].

Like:

Code: Select all

putserv "KICK $chan [join $temp ,] :$reason"
To:

Code: Select all

putserv "KICK $chan [join $temp ,] :[getrandomreason]"
If you want it to use one (random) reason, simply change

Code: Select all

set reason [string map [list ":ban:" "$ban" ":nick" "$nick"] $enforce(kmsg)]
To

Code: Select all

set reason [getrandomreason]
Now if you still don't understand how this all works, then I suggest you give up on using eggdrops.
Post Reply