/*
 * ban removers, 1993
 * This script requires ircII-EPIC.
 */

# returns 1 if $0 matches or is matched by $1, 0 if not.
alias comatch @ function_return = (rmatch($0 $1) || rmatch($1 $0))

alias deban_mode {
        fe ($*) bx by bz {
                @ moder = bz?[-bbb]:by?[-bb]:bx?[-b]:[]
                if (moder) {
                        mode * $moder $bx $by $bz
                }
        }
}

# remove all bans on current channel
alias deban uniban *

# remove all bans that could cover nickname
alias unban uniban $0!$uh($0)

# remove all bans matching or matched by pattern
alias uniban {
        @ aa.unibanlist = []
	stack push on 367
	stack push on 368
        ^on ^367 * if \(comatch\($0 $$2\)\) { push aa.unibanlist $2 }
        ^on ^368 * {
		stack pop on 367
		stack pop on 368
		eval deban_mode $aa.unibanlist
	}
        ^mode ${[$1]?[$1]:C} +b
}


# remove all bans that contain a literal text substring
alias nban {
	@ aa.nbanlist = []
	stack push on 367
	stack push on 368
        eval ^on ^367 * if \(rmatch\($$2 *$0*\)\) { push aa.nbanlist $2 }
	^on ^368 * {
		stack pop on 367
		stack pop on 368
		deban_mode $aa.nbanlist
	}
        ^mode ${[$1]?[$1]:C} +b
}

#hop'93
