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 

Enforce Ban
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Mon Oct 02, 2006 4:08 am    Post subject: Reply with quote

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 Very Happy

Code:

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."
Back to top
View user's profile Send private message
sdays
Halfop


Joined: 21 Oct 2006
Posts: 98

PostPosted: Tue Oct 24, 2006 12:34 am    Post subject: . Reply with quote

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

Code:

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."
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Tue Oct 24, 2006 5:02 am    Post subject: Reply with quote

Why do you even use that version?

This is a much cleaner version.

Code:
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:
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:
putserv "KICK $chan [join $temp ,] :$reason"


To:

Code:
putserv "KICK $chan [join $temp ,] :[getrandomreason]"


If you want it to use one (random) reason, simply change

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


To

Code:
set reason [getrandomreason]


Now if you still don't understand how this all works, then I suggest you give up on using eggdrops.
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 -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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