############################
### CopyVoice.tcl        ###
### Version 1.2          ###
### By Wcc               ###
### wcc@techmonkeys.org  ###
### http://dawg.dynu.com ###
### EFnet #|DAWG|Tcl     ###
############################

############################################################################
### Copyright © 2000 - 2001 |DAWG| Scripting Group. All rights reserved. ###
############################################################################

###########################################################################
## This script voices everyone voiced in one channel on another channel. ##
###########################################################################

##############
## COMMANDS ##
#############################################
## PUB ## !copyvoice <channel1> <channel2> ##
######### Copys the voiced users from the  ##
######### first channel to the second.     ##
#############################################
## DCC ## .copyvoice <channel1> <channel2> ##
######### Copys the voiced users from the  ##
######### first channel to the second.     ##
#############################################

##########################################################
## Just load the script, edit the settings, and rehash. ##
##########################################################

###################################
# Enable use of bold in DCC chat? #
###################################

set copyvoice_setting(bold) 1

#############################################
# Prefix "COPYVOICE:" in DCC chat messages? #
#############################################

set copyvoice_setting(COPYVOICE:) 1

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

if {![string match 1.6.* $version]} { putlog "\002COPYVOICE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." }
if {[info tclversion] < 8.2} { putlog "\002COPYVOICE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

bind pub o|o !copyvoice copyvoice_pub
bind dcc - copyvoice copyvoice_dcc

proc copyvoice_dopre {} {
	global copyvoice_setting
	if {!$copyvoice_setting(COPYVOICE:)} { return "" }
	if {!$copyvoice_setting(bold)} { return "COPYVOICE: " }
	return "\002COPYVOICE:\002 "
}
proc copyvoice_pub {nick uhost hand chan text} {
	set text [split $text]
	if {[lindex $text 1] == ""} { putserv "NOTICE $nick :Usage: !copyvoice <channel1> <channel2>" ; return }
	if {![validchan [lindex $text 0]] || ![botonchan [lindex $text 0]]} { putserv "NOTICE $nick :[join [lindex $text 0]] is not a valid channel." ; return }
	if {![validchan [lindex $text 1]] || ![botonchan [lindex $text 1]]} { putserv "NOTICE $nick :[join [lindex $text 1]] is not a valid channel." ; return }
	if {![botisop [lindex $text 1]]} { putserv "NOTICE $nick :I do not have ops on [join [lindex $text 1]]." ; return }
	set v 0
	foreach u [chanlist [lindex $text 0]] {
		if {![isvoice $u [lindex $text 0]] || [isvoice $u [lindex $text 1]]} { continue }
		pushmode [lindex $text 1] +v $u
		incr v
	}
	putserv "NOTICE $nick :$v voices copied."
}
proc copyvoice_dcc {hand idx text} {
	set text [split $text]
	if {[lindex [split $text] 1] == ""} { putdcc $idx "[copyvoice_dopre]Usage: !copyvoice <channel1> <channel2>" ; return }
	if {![validchan [lindex $text 0]] || ![botonchan [lindex $text 0]]} { putdcc $idx "[copyvoice_dopre][join [lindex $text 0]] is not a valid channel." ; return }
	if {![validchan [lindex $text 1]] || ![botonchan [lindex $text 1]]} { putdcc $idx "[copyvoice_dopre][join [lindex $text 1]] is not a valid channel." ; return }
	if {![botisop [lindex $text 1]]} { putdcc $idx "[copyvoice_dopre]I do not have ops on [join [lindex $text 1]]." ; return }
	set v 0
	foreach u [chanlist [lindex $text 0]] {
		if {![isvoice $u [lindex $text 0]] || [isvoice $u [lindex $text 1]]} { continue }
		pushmode [lindex $text 1] +v $u
		incr v
	}
	putdcc $idx "[copyvoice_dopre]$v voices copied."
}
putlog "\002COPYVOICE:\002 CopyVoice.tcl Version 1.2 by Wcc is loaded."