######################################################################
### Botnetmaint1.2.tcl  By Gothic gothic@web-america.com           ###
### 		 			           		   ###
### GREETS: -Teknikali, JD, watcher, cyclopse, jd||                ###
###                                                                ###
### This is the first public version of this script.               ###
###                                                                ###
### This script adds botnet wide functionality for easier sync'ing ###
### of bans, rehashes, and +/- chan's etc...                       ###
### Commands:  .+bchan .-bchan  will make all bots on the botnet   ###
### Running this script join/part a channel with +autoop set on    ###
### once op'd use .secure #channel  to shut autoop off on all bots ###
### .+/-bban *!*@banmask.dom  will add or remove a ban on all bots ###
### .brestart will make all bots restart                           ###
###                                                                ###
### if you have any problems or suggestions or you like this and   ###
### use it ... please send me some email so i can keep track of    ###
### the number of people using it .. and i can mail you updates.   ###
### Thanks specifically to Teknikali.                              ###
###                                                                ###
### IMPORTANT for a person to use this script and commands to work ###
### you must have flags 7 to +/-bchan's and 9 to +/-bban's and +m  ###
### to restart the bots.                                           ###
######################################################################


################
### bindings ###
################

bind dcc 7 +bchan own_chan
bind dcc 7 -bchan unown_chan
bind dcc 9 +bban botnet_ban
bind dcc 9 -bban botnet_unban
bind dcc 7 secure secure
bind dcc m brestart botnet_restart

bind bot - switchown bots_own
bind bot - leavechown bots_leave
bind bot - botnetban botsnet_ban
bind bot - botnetunban botsnet_unban
bind bot - securechown bots_secure
bind bot - botnetrestart bots_restart

#######################
###    the procs    ###
#######################
###  own chan proc  ###
#######################
 
proc own_chan {bot idx args} {
  set arg [lindex $args 0]
  set ownchan [lindex $args 0]
  putallbots "switchown $ownchan"
  putlog "!!  Owning $ownchan  !!"
  channel add $ownchan
  channel set $ownchan chanmode +stn
  channel set $ownchan +autoop
  return 0
}

proc bots_own {bot command args} {
  global ownchan
  set ownchan [lindex $args 0]
  putlog "!!  Owning $ownchan  -  from $bot  !!" 
  channel add $ownchan
  channel set $ownchan chanmode +stn
  channel set $ownchan +autoop
  return 1
}

#########################
### Leave the channel ###
#########################

proc unown_chan {bot idx args} {
  set arg [lindex $args 0]
  set ownchan [lindex $args 0]
  putallbots "leavechown $ownchan"
  putlog "!! Leaving $ownchan  !!"
  channel remove $ownchan
  return 0
}

proc bots_leave {bot command args} {
  global ownchan
  set ownchan [lindex $args 0]
  putlog "!! Leaving $ownchan  -  from $bot  !!" 
  channel remove $ownchan
  return 1
}

##########################
### Secure the channel ###
##########################

proc secure {bot idx args} {
  set arg [lindex $args 0]
  set ownchan [lindex $args 0]
  putallbots "securechown $ownchan"
  putlog "!!  Securing $ownchan  !!"
  channel set $ownchan -autoop
  return 0
}

proc bots_secure {bot command args} {
  global ownchan
  set ownchan [lindex $args 0]
  putlog "!! Securing $ownchan  -  from $bot  !!" 
  channel set $ownchan -autoop
  return 1
}

########################
### Bot Net Ban Shit ###
########################

proc botnet_ban {bot idx args} {
  set band [lindex $args 0]
  set bandmask [lindex $band 0]
  set commentz [lrange $band 1 end]
  putallbots "botnetban $bandmask $commentz 0"
  putlog "!! banning $bandmask - Perm Ban ALL CHANNELS !!"
  newban $bandmask $bot $commentz 0
  return 0
}

proc botsnet_ban {bot command args} {
  
  set band [lindex $args 0]
  set bandmask [lindex $band 0]
  set commentz [lrange $band 1 end]
  putlog "!! Banning $bandmask - Perm Ban ALL Channels - from $bot !!"
  newban $bandmask $bot $commentz 0
  return 1
}
proc botnet_unban {bot idx args} {
  set band [lindex $args 0]
  set bandmask [lindex $band 0]
  putallbots "botnetunban $bandmask"
  putlog "!! Removing $bandmask - From ban list !!"
  killban $bandmask
  return 0
}

proc botsnet_unban {bot command args} {
  set band [lindex $args 0]
  set bandmask [lindex $band 0]
  putlog "!! Removing $bandmask - From ban list - from $bot !!"
  killban $bandmask
  return 1
}

######################
### botnet restart ###
######################

proc botnet_restart {bot idx args} {
  putallbots "botnetrestart"
  putlog "!! Restarting !!"
  restart
  return 0
}

proc bots_restart {bot command args} {
  putlog "!! Restart  -  from $bot  !!"
  restart
  return 1
}
  

#############################
### declare it was loaded ###
#############################

putlog "!!  BotnetMaint1.2.TCL by Gothic & Teknikali (of haktik) loaded  !!"
