#OperCheck.tcl By Drago & sinkhole.
#Death Threats/Mail Bombs/Hate Mail, Go To: Drago (Drago@Drago.com)
#
#http://ShadowNET.home.ml.org
##
##          This TCL Should Only Be Used By BotNet Admins.            ##
## Please Don't Try To Load This On A Limbo Bot, That Would Be Stupid.##
##    For This TCL To Work You Must Compile With Raw #define'd.       ## 
##   This TCL Will Do A Whois/Whowas On Any Nick That Is Fluded.      ##
##If The Raw Whois/Whowas Returns 313 (Oper Raw) It Will Broadcast It.## 
##
#Operator Fluds Will Be Broadcasted On Level 2. (.console +2)
#All Fluds Will Be Broadcasted On Level 3. (.console +3)
#Logs Can Be Accessed By Typing '.getlogs'.  (Will Be Sent Over iRC)
##
####!!!!!!!Don't Edit This In pico, Simply Because It Suxs!!!!!!!!!!####
#####################################Notes:#################################################
#I Was Not Able To Get The TCL To Broadcast Who Fluded The Oper Because Of Timing Problems.#
#So To Find Out, Check Both Logs Against Each Other.                                       #
#Check operfluds.log First And If You See A Oper Flud, Check It Against whofluded.log.     #
############################################################################################

set whonote "?"          ;#Who To Send The Note To When A Oper Is Fluded. (Must Be Local)
set fluda   0            ;#Allow 'Flud' Checking.
set flud3a  1            ;#Allow 'Flud3' Checking.
set lev2 "operfluds.log" ;#Level 2 Log File (Oper Fluds).
set lev3 "whofluded.log" ;#Level 3 Log File (All Fluds).
set broadt 0             ;#Broadcast Oper Flud's Public (0/1).


	  ########FR33Z3##########

##Nothing Needs To Be Modified Below This##
bind bot - flud bot_flud
bind bot - flud3 bot_flud
logfile 2 * $lev2
logfile 3 * $lev3
dccbroadcast "OperCheck.tcl By Drago & sinkhole Loaded. http://ShadowNET.home.ml.org"
putlog "OperCheck.tcl By Drago & sinkhole Loaded. http://ShadowNET.home.ml.org"
if {$fluda == "1"}  {
	bind bot - flud bot_flud
	putlog "#OperCheck#: Binding Flud."
} else {
	putlog "#OperCheck#: Unbinding Flud."
	unbind bot - flud bot_flud
}
if {$flud3a == "1"}  {
	bind bot - flud3 bot_flud
	putlog "#OperCheck#: Binding Flud3."
} else {
	putlog "#OperCheck#: Unbinding Flud3."
	unbind bot - flud3 bot_flud
}

#Letz Get Started.#
bind raw - "% 313 *" on313_do
proc on313_do {raw} {
	global whodid broadt whonote nick
	set oper [lindex "$raw" 3]
	set oper1 "#OperCheck#: $oper Was Fluded - Contacting Admins. ****"
	if {$broadt == "0"}  {
	putloglev 2 * "<Level 2> $oper1"
	putlog $oper1
	sendnote OperCheck $whonote "#OperCheck#: $oper Was Fluded (iRC Oper.)"	
	return 0
}
	dccbroadcast $oper1	
	putloglev 2 * "<Level 2> $oper1"
	sendnote OperCheck $whonote "#OperCheck#: $oper Was Fluded (iRC Oper.)"
}

proc bot_flud {bot cmd arg} {
	global whodid
	set who [lindex "$arg" 2]
	set oper2 [lindex "$arg" 0]
	set whodid "$who@$bot"
	putloglev 3 * "<Level 3> $whodid Fluded: $oper2"
        set stealthy [lsearch -regexp $oper2 ,]
	if {$stealthy == "0"}  {
        putserv "whois $oper2"
	putserv "whowas $oper2"
	return 0
}
        putserv "whois $oper2 $oper2"
	putserv "whowas $oper2 $oper2"
}

bind dcc n getlogs get_logs
proc get_logs {hand idx arg} {
	global lev2 lev3
	set arg1 [lindex "$arg" 0]
	if {$arg1 == ""}  {
	putdcc $idx "No Nick Specified To Send To.  Sending Flud Logs To $hand By Default."
	dccsend $lev2 $hand
	dccsend $lev3 $hand
	putlog "#$hand# getlogs" 
	return 0
}
	putdcc $idx "Sending Flud Logs To $arg1."
	dccsend $lev2 $arg1
	dccsend $lev3 $arg1
	putlog "#$hand# getlogs $arg1"
}
