###########################
### OpNotice.tcl	###
### Version 1.1		###
### By Wcc		###
### irc.dal.net		###
###########################

#####################################################################
## This script sends a notice or privmsg to all ops on a channel.  ##
#####################################################################

##############
## COMMANDS ##
##########################################################
## DCC ## .onotice <channel> <message>			##	
######### Sends a notice to all ops on the channel you  ##
######### specify. Requires that the sender have +o for	##
######### the channel. The bot must be opd for a user to##
######### send an op notice.				##
######### NOTE: Owners (+n) can override this.		##
######### --------------------------------------------- ##
######### .omsg <channel> <message>			##
######### Sends a privmsg to all ops on the channel you ##
######### specify. Requires that the sender have +o for	##
######### the channel. The bot must be opd for a user to##
######### send an op notice.				##
######### NOTE: Owners (+n) can override this.		##
##########################################################

######################################
## Just load the script and rehash. ##
######################################

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

bind dcc - onotice send_onotice
bind dcc - omsg send_onotice

proc send_onotice {hand idx text} {
	global botnick
	if {([lindex $text 0] == "") || ([lindex $text 1] == "")} {
		putidx $idx "OPNOTICE: Usage: .onotice <channel> <message>"
	} else {
		set chan [lindex $text 0]
		set msg [lrange $text 1 end]
		if {([matchattr $hand o|o $chan])} {
			if {([botisop $chan]) || ([matchattr $hand +n])} {
				foreach i [chanlist $chan] {
					if {([isop $i $chan]) && ($i != $botnick)} {
						putserv "NOTICE $i :OPNOTICE: Op notice from $hand: $msg"
					}
				}
			} else {
				putidx $idx "OPNOTICE: I am not opd in $chan and you do not have access to override."
			}
		} else {
			putidx $idx "OPNOTICE: Access denied."
		}
	}
}

proc send_omsg {hand idx text} {
	global botnick
	if {([lindex $text 0] == "") || ([lindex $text 1] == "")} {
		putidx $idx "OPNOTICE: Usage: .omsg <channel> <message>"
	} else {
		set chan [lindex $text 0]
		set msg [lrange $text 1 end]
		if {([matchattr $hand o|o $chan])} {
			if {([botisop $chan]) || ([matchattr $hand +n])} {
				foreach i [chanlist $chan] {
					if {([isop $i $chan]) && ($i != $botnick)} {
						putserv "NOTICE $i :OPNOTICE: Op message from $hand: $msg"
					}
				}
			} else {
				putidx $idx "OPNOTICE: I am not opd in $chan and you do not have access to override."
			}
		} else {
			putidx $idx "OPNOTICE: Access denied."
		}
	}
}

putlog "OPNOTICE: OpNotice.tcl Version 1.1 by wcc is loaded."