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.

bot set ban

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
f
fls
Voice
Posts: 35
Joined: Wed Oct 17, 2007 10:55 pm

bot set ban

Post by fls »

Hey guys,

Is there a script for this listed?

IF a user been kick by any op 3 times and the bot will auto set ban on tat user within a period of time let say 10mins.

can the period of time be change/updated too?

can the bot auto unban after a period of time too?

OP level will be excuse for this ban


Regard
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Untested, may do some testing later on.

Code: Select all

#header
# kicklimit.tcl version 1.0 by TCL_no_TK <ispmailsucks@googlemail.com>

#description
# Allows you to set limits on how many times users (from a host) may be kicked
# from the channel, per channel limiting/enabling/ban messages.

#info
# Usage:
#  .chanset <#channel> +kicklimit  -- enables
#  .chanset <#channel> -kicklimit  -- disables
#  .chanset <#channel> kicklimit-kicks 3 -- sets the max kicks for a host to 3
#  .chanset <#channel> kicklimit-reason "You have been banned from #channel for being kicked 3 times!" -- sets the ban reason for that channel.
#  .chanset <#channel> kicklimit-bantime 2d4h -- sets the bantime for the channel to 2 days and 4 hours.
#                                                <time> format <X>[d]<X>[h]
#                                                <minets> format @<number-of-minets>
#

#notes
# The exempt options for channel ops, halfops and voices use the 'wasop' fuction
# and may not provide the correct fuction it is used for in this script. *take a chance*

#settings
# use a channel ban, when adding a ban on host
# that reaches its kick limit for any channels set +kicklimit
# 0/1 = no/yes
set kicklimit(channelban) "0"

# (same as above) only will add channel ban on the bot; 0 (disable) 1 (enable)
set kicklimit(botban) "1"

# exempt flags '[global]-|-[channel]'
set kicklimit(exempt-flags) "bolvf|olvf"

# exempt channel ops; 0 (disable) 1 (enable)
set kicklimit(exempt-ops) "1"

# exempt channel halfops; 0 (disable) 1 (enable)
set kicklimit(exempt-hops) "1"

# exempt channel voices; 0 (disable) 1 (enable)
set kicklimit(exempt-vops) "1"

# set the maximum length of the ircd's kick message's
set kicklimit(max-kicklength) "255"

#code
proc kick:kicklimit {nick host handle channel target reason} {
global kicklimit
 if {(![isbotnick $target]) && (![validuser [nick2hand $target]]) && ([kicklimit:swa "$target" "$channel"])} {
  kicklimit:host "$target" "[getchanhost $target]" "$channel"
   return
 }
 if {(![isbotnick $target]) && ([validuser [nick2hand $target]]) && ([kicklimit:dmef "$target" "$channel"]) && ([kicklimit:swa "$target" "$channel"])} {
  kicklimit:host "$target" "[getchanhost $target]" "$channel"
   return
 }
}

proc kicklimit:swa {target channel} {
global kicklimit
 if {($::kicklimit(exempt-ops) != "") && ($::kicklimit(exempt-ops) == "1") && ([wasop $target $channel])} {
  set swa "0"
 }
 if {($::kicklimit(exempt-hops) != "") && ($::kicklimit(exempt-hops) == "1") && ([washalfop $target $channel])} {
  set swa "0"
 }
 if {($::kicklimit(exempt-vops) != "") && ($::kicklimit(exempt-vops) == "1") && ([wasvoice $target $channel])} {
  set swa "0"
 }
  if {(![info exists swa])} {set swa "1"}; return $swa
}

proc kicklimit:dmef {target channel} {
global kicklimit
 if {($::kicklimit(exempt-flags) != "")} {
  set flags $::kicklimit(exempts-flags)
   if {[matchattr [nick2hand $target] $flags $channel]} {
    return 0
   } else {
    return 1
   }
 }; return 0
}

proc kicklimit:host {nick host channel} {
global kicklimit
 if {(![string match -nocase "*@*" "$host"])} {set khost "$nick!*@*"} else {set khost "*!*@[lindex [split $host "@"] 1]"}
  if {([channel get $channel kicklimit] == "-")} {return}
   if {($::kicklimit($channel:$khost) != "")} {
    set kicklimit($channel:$khost) "1"
     return
   }
    if {([channel get $channel kicklimit-kicks] != "") && ($::kicklimit($channel:$khost) < [channel get $channel kicklimit-kicks])} {
     set kicklimit($channel:$khost) [expr $::kicklimit($channel:$khost) +1]
      return
    }
     if {([channel get $channel kicklimit-kicks] != "") && ($::kicklimit($channel:$khost) == [channel get $channel kicklimit-kicks])} {
      kicklimit:punish "$nick" "$host" "$channel"
       return
     }
     if {([channel get $channel kicklimit-kicks] != "") && ($::kicklimit($channel:$khost) > [channel get $channel kicklimit-kicks])} {
      set kicklimit($channel:$khost) "0"
       return
     }
}

proc kicklimit:punish {nick host channel} {
global kicklimit
 set bhost [kicklimit:checkhost "$nick" "$host"]
  if {($::kicklimit(channelban) != "") && ($::kicklimit(channelban) == "1")} {
   kicklimit:chanban "$nick" "$bhost" "$channel"
    return
  }
   if {($::kicklimit(botban) != "") && ($::kicklimit(botban) == "1")} {
    kicklimit:botban "$nick" "$bhost" "$channel"
     return
   }
}

proc kicklimit:chanban {nick host channel} {
global kicklimit
 if {($::kicklimit(max-kicklength) == "")} {
  set kmml "255"
 } else {
  set kmml $::kicklimit(max-kicklength)
 }
  if {([channel get $channel kicklimit-reason] == "")} {
   set kreason [kicklimit:trimchars "Kick limit for your host has expired." "$kmml"]
  } else {
   set kreason [kicklimit:trimchars "[channel get $channel kicklimit-reason]" "$kmml"]
  }
   if {([channel get $channel kicklimit-bantime] == "")} {
    set bantime "15"
   }
    if {([channel get $channel kicklimit-bantime] != "")} {
     set btime [channel get $channel kicklimit-bantime]
      if {([string match "@*" "$btime"])} {
       set bantime [lindex [split $btime "@"] 1]
      } else {
       set bantime [kicklimit:mc:bantime "$btime"]
      }
   }
    putquick "MODE $channel :+b $host"
     putquick "KICK $channel $nick :$kreason"
      timer $bantime {putserv "MODE $channel :-b $host"}
       return
}

proc kicklimit:botban {nick host channel} {
global kicklimit
 if {($::kicklimit(max-kicklength) == "")} {
  set kmml "255"
 } else {
  set kmml $::kicklimit(max-kicklength)
 }
  if {([channel get $channel kicklimit-reason] == "")} {
   set kreason [kicklimit:trimchars "Kick limit for your host has expired." "$kmml"]
  } else {
   set kreason [kicklimit:trimchars "[channel get $channel kicklimit-reason]" "$kmml"]
  }
   if {([channel get $channel kicklimit-bantime] == "")} {
    set bantime "15"
   }
    if {([channel get $channel kicklimit-bantime] != "")} {
     set btime [channel get $channel kicklimit-bantime]
      if {([string match "@*" "$btime"])} {
       set bantime [lindex [split $btime "@"] 1]m
      } else {
       set bantime [kicklimit:mc:bantime "$btime"]m
      }
   }
    newchanban $channel $host "kicklimit.tcl" "$kreason" "$bantime" none
     if {([isban $host $channel])} {return} else {return}
}

proc kicklimit:checkhost {nick host} {
 if {(![onchan $nick])} {return "$host"}
  if {(![string match "*@*.*" "$host"])} {
   set new_host "*!*@[lindex [split [getchanhost $nick] "@"] 1]"
    if {([string match -nocase "$host" "$new_host"])} {
     return "$host"
    } else {
     return "$new_host"
    }
  }
   set new_host "*!*@[lindex [split [getchanhost $nick] "@"] 1]"
    if {([string match -nocase "$host" "$new_host"])} {
     return "$host"
    } else {
     return "$new_host"
    }
}

proc kicklimit:mc:bantime {time} {
 if {$time == ""} {return 0}
  if {![regexp -- {^([0-9]*[dhm])([0-9]*[dhm])?([0-9]*[dhm])?$} $time]} {
   return 0
  } else {
   set e $time
    if {![regexp -- {([0-9]*)m} $e -> min]  || ($min == "")}  {set min  0}
     if {![regexp -- {([0-9]*)h} $e -> hour] || ($hour == "")} {set hour 0}
      if {![regexp -- {([0-9]*)d} $e -> day]  || ($day == "")}  {set day  0}
       set expire [expr ($min*60)+($hour*3600)+($day*86400)]
  }; return [expr ($expire/60)]
}

proc kicklimit:trimchars {chars index} {return [join [lrange "[split "$chars" {}]" 0 $index] {}]}

#binds
bind kick - "* * *" kick:kicklimit

#channel options
setudef flag kicklimit
setudef str kicklimit-kicks
setudef str kicklimit-reason
setudef str kicklimit-bantime

#end
putlog "loaded kicklimit.tcl version 1.0 by TCL_no_TK"
return
Feel free to point out errors/bugs and i'll fix them, its rough as always.
btw, the script will allow channelban's and botbans to enabled dont wanna change this :P just call it a "special" feature :roll:
The script will reset a hosts kick limit if it detects it has gone over the allowed channel limit... (this wont affect channels having differant limits) but if you wish to disable it remove the following line of code (what this will do is auto ban any host that has been kicked more than the allowed limit for the channel, not allowed them to reuse up 3 more limits)

Code: Select all

     if {([channel get $channel kicklimit-kicks] != "") && ($::kicklimit($channel:$khost) > [channel get $channel kicklimit-kicks])} {
      set kicklimit($channel:$khost) "0"
       return
     } 
from kicklimit:host proc. The bantime code from MC_8 :) Thx MC_8 :D P.S sorry for the late reply.
f
fls
Voice
Posts: 35
Joined: Wed Oct 17, 2007 10:55 pm

Post by fls »

Hi mate, appreciate. tks u
Post Reply