# ------------ echoXinviter Remover ----------------------------------------
#
#  Version : 1.1
#  Author  : blessing @ DALnet
#  Release : March 2010
#
#  Description ::
#
#  Removes / kickbans user that uses echoXinviter Script.
#  Detection pattern is based on echoXinviter source script.
#
#  Change log :
#   1.0 - First public release.
#   1.1 - Adding bantime.
#       - Some echox phrase/names with 10+ chars will not detected as echoX 
#         if being used as identd. This is limition of some IRCd which only 
#         allows max 10 chars as identd. Now fixed.
#       - If no bugs found, this release will considered as final release.
#
#---------------------------------------------------------------------------

# To enable echoX detection use DCC command:
#   .chanset <channel> +echox 

# Set kick message here
set echox(kmsg) "10-14ap4n10-10 Banned: \[spam/echoX\] - Lamer.. Get lost!"

# Set bantime (in minutes) here ( 0 = perm )
set echox(bantime) 30


#--------------------------------------------------------------
# Dont touch anything below unless you know what you doing :)
#--------------------------------------------------------------

bind join - * echox
bind mode - "* -b*" bleh

setudef flag echox

set echox(list) { adams allen allison alvarez anderson andrews armstrong arnold avila bailey baker barnes bennett bishop boyd bradley brooks brown bryan burke burton butler campbell carlson carr carter chase chen christensen clark collins comer cook cooper cox crawford cunningham davis day dean dickinson edwards elliott ellis evans fischer fisher fong ford freeman frost garcia gardner gomes gomez gonzales graham green griffin hall hamilton hansen hanson harris harrison hartman harvey hayes henderson henry hernandez hill holmes howard hughes hunt jackson jensen johnson jones keller kelley kennedy king lane long lopez marsh martinez mathews matthews mcdonald miller mitchell moore morgan morris nelson newton obrien oconnor olsen palmer parker patterson peck perkins perry peterson phillips powell price randolph reed rice richardson rivera rivers roberts robinson rodrigues rodriguez rogers romero ruis sanders santos shaw short silva simpson smith snyder spafford spencer springer stafford stewart stone sullivan taylor thompson turner walker wallace walton ward warner watson weber wells white williams wong wood woods wright young }

proc echox {nick uhost hand chan} {
  global echox
  if {[matchattr $hand fmo|fmo $chan] || ![botisop $chan] || [llength [split $nick _]] < 2} {return 0}
  set id [string map {"~" ""} [lindex [split $uhost @] 0]] ; set n [lindex [split $nick _] end]
  if {![string match -nocase $id* $nick] && [lsearch -exact $echox(list) $n] != -1 && ([lsearch -exact $echox(list) $id] != -1 || ([lsearch -glob $echox(list) $id*] != -1 && [string length $id] >= 9)) && [channel get $chan echox]} {
    putquick "KICK $chan $nick :$echox(kmsg)"
    putquick "MODE $chan +b [set bm *!*@[lindex [split $uhost @] 1]]"
    if {[set tid [lsearch -glob [string tolower [timers]] "*pushmode $chan -b $bm*"]] != -1} { killtimer [lindex [lindex [timers] $tid] 2] }
    if {$echox(bantime) > 0} { timer $echox(bantime) [list pushmode $chan -b $bm] }
    putlog "$chan : echoXinviter detected.. ( $nick!$uhost )"
  }
}

proc bleh {nick uhost hand chan m targ} {
  if {[set tid [lsearch -glob [string tolower [timers]] "*pushmode $chan -b $targ*"]] != -1} { 
    killtimer [lindex [lindex [timers] $tid] 2]
  }
}

putlog "10-14ap4n10-10 echox.tcl successfully loaded... :)"
