# AutoOp   by Ian Frechette 12-10-92 
# EPIC modifications as necessary by Jeremy Nelson

# the people you want to be opped by default.  Wildcards are allowed.
# the patterns must be of the form user@host
if (!op_list) 
	{@ op_list = [bob@example.bob.edu foo@*.bar.com]}

# the channels you want people to be opped on by default.  Wildcards
# are allowed.  '*' simply means all channels apply.
if (!chan_list)
	{@ chan_list = [* #example]}

# Show the the people currently in the autoop list
alias showop
{
	@ count = 0
	@ ao.name = []
	echo *** AutoOp list.  Addop user@host to add.  Delop <num>  to remove
	echo *** <num> nickname!username@hostname 
	for ao.name in ($op_list) {
		echo *** $[5]count $ao.name
		@ count++
	}
}

# Just like showop but works with channels.
alias showchan
{
	@ count = 0
	@ ao.name = []
	echo *** AutoOp chan list.  Addchan #channel add.  Delchan <num>  to remove
	echo *** <num> #channel
	for ao.name in ($chan_list) {
		echo *** $[5]count $ao.name
		@ count++
	}
}

# Given a number.. deletes that person from the autoop list.. 
# use SHOWOP to list.
alias delop {
    if (rmatch("$0" *1 *2 *3 *4 *5 *6 *7 *8 *9 *0))
        { @ op_list = notw($0 $op_list) }
        { echo *** Usage: delop <number>;echo *** See showop }
}
    
# Given a number.. deletes that channel from the autoop channel list.. 
# use SHOWCHAN to list.
alias delchan {
    if (rmatch("$0" *1 *2 *3 *4 *5 *6 *7 *8 *9 *0))
        { @ chan_list = notw($0 $chan_list) }
        { echo *** Usage: delchan <number>;echo *** See showchan }
}

# Add an autochanop to the list.
alias addop {
    if ([$0])
	{ push op_list $0 }
	{ echo *** Usage addop username@host;echo *** wildcards are allowed }
}

# Add an autochanop channel to the list.
alias addchan {
    if ([$0])
	{ push chan_list $0 }
	{ echo *** Usage addchan #channel;echo *** wildcards are allowed }
}

#
# the actual ON that does the work
# This is the hook as it would be used in ircii-EPIC
#
on #-join 666 '% \\[$chan_list\\] \\[$op_list\\]' {
	timer ${10 + rand(10)} if \(!ischanop\($0 $1\)\) \{//mode $1 +o $0\}
}
