####################################
### BotnetNotify.tcl		 ###
### Version 1.2			 ###
### By Wcc			 ###
### irc.dal.net			 ###
####################################

############################################################################################
## This script notifies a channel what a user joins the partyline, when a user leaves	  ##
## the partyline, when a bot disconnects, when a bot links, and when a user changes there ## 
## handle. If bnethubon is set to 1, it will notify when any bot links or delinks.	  ##										  ##
############################################################################################

#############################################################
## Just load the script, set the variables, and rehash.    ##
#############################################################

######################################
# Set your botnet info channel here. #
######################################

set bnetinfochan "#Channel"

######################################
# If your bot is a hub set "1" here. #
######################################

set bnethubon 0

####################
# Code begins here #
####################

bind chon - * user_login
bind chof - * user_logout
bind link - * bot_link
bind disc - * bot_disconnect
bind nkch - * user_handchange
bind filt - .quit* user_quit

proc user_login {hand idx} {
	global bnetinfochan botnick
	putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $hand has joined the partyline."
}

proc user_logout {hand idx} {
	global bnetinfochan botnick
	putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $hand has left the partyline. \(Disconnected\)."
}

proc bot_link {botname to} {
	global bnetinfochan botnick bnethubon
	if {$bnethubon} {
		putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $botname is now linked to $to." 
	}
}	

proc bot_disconnect {botname} {
	global bnetinfochan botnick bnethubon
	if {$bnethubon} {
		putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $botname has disconnected from the botnet." 
	}
}	


proc user_handchange {oldhand newhand} {
	global bnetinfochan botnick	
	putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $oldhand is now known as $newhand."
}

proc user_quit {hand quitmsg} {
	global bnetinfochan botnick
	if {[llength $quitmsg] > 1} {
		putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $hand has left the partyline. \([lrange [split $quitmsg] 1 end]\)."
	} else {
		putserv "PRIVMSG $bnetinfochan :BOTNETNOTIFY: $hand has left the partyline. \(Quit\)."
	}
}

putlog "BOTNETNOTIFY: BotnetNotify.tcl Version 1.2 by wcc is loaded."
putlog "BOTNETNOTIFY: Botnet info is being sent to $bnetinfochan."
if {$bnethubon} {
	putlog "BOTNETNOTIFY: Hub Mode is on."
} else {
	putlog "BOTNETNOTIFY: Leaf Mode is on."
}