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

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

#####################################################################
## 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. The sender must have +o for ##
######### the channel. The bot must be op'd for a  ##
######### user to send an op notice. NOTE: Owners  ##
######### (+n) can override this.                  ##
######### ---------------------------------------- ##
######### .omsg <channel> <message>                ##
######### Sends a msg to all ops on the channel    ##
######### you specify. The sender must have +o for ##
######### the channel. The bot must be op'd for a  ##
######### user to send an op notice. NOTE: Owners  ##
######### (+n) can override this.                  ##
#####################################################

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

###################################
# Set the op-notice command here. #
###################################

set opnotice_setting(onotice) "onotice"

################################
# Set the op-msg command here. #
################################

set opnotice_setting(omsg) "omsg"

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

set opnotice_setting(bold) 1

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

set opnotice_setting(OPNOTICE:) 1

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

if {$numversion < 1060800} { putlog "\002OPNOTICE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.8 or later." }
if {[info tclversion] < 8.2} { putlog "\002OPNOTICE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

bind dcc - $opnotice_setting(onotice) opnotice_onotice
bind dcc - $opnotice_setting(omsg) opnotice_omsg

proc opnotice_dopre {} {
	global opnotice_setting
	if {!$opnotice_setting(OPNOTICE:)} { return "" }
	if {!$opnotice_setting(bold)} { return "OPNOTICE: " }
	return "\002OPNOTICE:\002 "
}
proc opnotice_onotice {hand idx text} {
	if {[lindex [split $text] 1] == ""} { putdcc $idx "[onotice_dopre]Usage: .onotice <channel> <message>" ; return }
	if {![matchattr $hand o|o [set chan [lindex [split $text] 0]]]} { putdcc $idx "[onotice_dopre]Access denied." ; return }
	if {![botisop $chan] && ![matchattr $hand +n]} { putdcc $idx "[onotice_dopre]I do not have ops on $chan, and you do not have access to override." ; return }
	foreach o [chanlist $chan] {
		if {[isop $o $chan] && ![isbotnick $o]} { putserv "NOTICE $o :Op notice from $hand: [lrange [split $text] 1 end]" }
	}
}
proc opnotice_omsg {hand idx text} {
	if {[lindex [split $text] 1] == ""} { putdcc $idx "[onotice_dopre]Usage: .onotice <channel> <message>" ; return }
	if {![matchattr $hand o|o [set chan [lindex [split $text] 0]]]} { putdcc $idx "[onotice_dopre]Access denied." ; return }
	if {![botisop $chan] && ![matchattr $hand +n]} { putdcc $idx "[onotice_dopre]I do not have ops on $chan, and you do not have access to override." ; return }
	foreach o [chanlist $chan] {
		if {[isop $o $chan] && ![isbotnick $o]} { putserv "PRIVMSG $o :Op msg from $hand: [lrange [split $text] 1 end]" }
	}
}
putlog "\002OPNOTICE:\002 OpNotice.tcl Version 1.8 by Wcc is loaded."