### !ADDOP <nick> [hand] [f]

proc pub_lol_addop {me b c chan arg} {
	set arg [charfilter $arg]
	global lol botnick
	if {![check $c $me $b]} {
		if {$lol(silent) == 1 || [checksilent $c]} {return 0}
                puthelp "NOTICE $me :You need to be identified to use this function. Type .identhelp in the partyline for more info. : \002/msg $botnick id <password>\002 or \002/msg $botnick silent <password>\002 to no more receive this warning."
		return 0
	}
	if {[llength $arg] < 1} {
		puthelp "NOTICE $me :\002Usage:\002 [string trim $lol(cmdchar)]addop <nick> \[hand\] \[f\]"
		return 0
	}
	set nick [lindex $arg 0]
	set alternate [lindex $arg 1]
	set f [strlwr [lindex $arg 2]]
	set bot [strlwr $botnick]
	set hostmask "$nick![getchanhost $nick $chan]"
	set hand [nick2hand $nick $chan]
	if {![onchan $nick $chan]} {
                puthelp "NOTICE $me :Sorry, but I don't see $nick in $chan."
		return 0
	}
	if {[strlwr $nick] == $bot} {
                puthelp "NOTICE $me :Sorry, but I can't addops myself."
		return 0
	}
	if {[getting-users]} {
                puthelp "NOTICE $me :Sorry, but I'm transferring the userfile, try later."
		return 0
	}
	if {$f == "f"} {
		if {![validuser $alternate]} {
			adduser $alternate [maskhost $hostmask]
			chattr $alternate +p|+o $chan
			puthelp "NOTICE $me :New user: $alternate ([maskhost $hostmask])"
                        puthelp "NOTICE $me :$nick added to the $chan oplist and party-line with the hand: $alternate."
                        puthelp "NOTICE $nick :You have been added to the $chan oplist and party-line by $me with the hand: $alternate."
			puthelp "NOTICE $nick :You must set a password type: \002/msg $botnick PASS <your_password>\002"
			if {[botisop $chan] && ![isop $nick $chan]} {
				pushmode $chan +o $nick
			}
			return 0
		}
		setuser $alternate HOSTS [maskhost $hostmask]
		chattr $alternate -|+o $chan
		puthelp "NOTICE $me :Added hostmask for $alternate: [maskhost $hostmask]"
                puthelp "NOTICE $me :$nick added to the $chan oplist with the hand: $alternate."
                puthelp "NOTICE $nick :You have been added to the $chan oplist by $me with the hand: $alternate."
		if {[botisop $chan] && ![isop $nick $chan]} {
			pushmode $chan +o $nick
		}
		return 0
	}
	if {![validuser $hand]} {
		if {[validuser $nick] && $alternate == ""} {
                        puthelp "NOTICE $me :The hand $nick already exists. \002Usage:\002 !addop <nick> <hand> \[f\]"
			return 0
		}
		if {$alternate != ""} {
			if {[validuser $alternate]} {
                                puthelp "NOTICE $me :The hand $alternate already exists. Choose another. \002Usage:\002 !addop <nick> <hand> \[f\]"
				return 0
			}
			adduser $alternate [maskhost $hostmask]
			chattr $alternate +p|+o $chan
			puthelp "NOTICE $me :New user: $alternate ([maskhost $hostmask])"
                        puthelp "NOTICE $me :$nick added to the $chan oplist and party-line with the hand: $alternate."
                        puthelp "NOTICE $nick :You have been added to the $chan oplist and party-line by $me with the hand: $alternate."
			puthelp "NOTICE $nick :You must set a password type: \002/msg $botnick pass <your_password>\002"
			if {[botisop $chan] && ![isop $nick $chan]} {
				pushmode $chan +o $nick
			}
			return 0
		}
		adduser $nick [maskhost $hostmask]
		chattr $nick +p|+o $chan
		puthelp "NOTICE $me :New user: $nick ([maskhost $hostmask])"
                puthelp "NOTICE $me :$nick added to the $chan oplist and party-line with the hand: $nick."
                puthelp "NOTICE $nick :You have been added to the $chan oplist and party-line by $me with the hand: $nick."
		puthelp "NOTICE $nick :You must set a password type: \002/msg $botnick pass <your_password>\002"
		if {[botisop $chan] && ![isop $nick $chan]} {
			pushmode $chan +o $nick
		}
		return 0
	}
	if {$alternate != ""} {
		if {[validuser $alternate]} {
                        puthelp "NOTICE $me :The hand $alternate already exists. \002Usage:\002 !addop <nick> <hand> \[f\]"
			return 0
		}
		adduser $alternate [maskhost $hostmask]
		chattr $alternate +p|+o $chan
		puthelp "NOTICE $me :New user: $alternate ([maskhost $hostmask])"
                puthelp "NOTICE $me :$nick added to the $chan oplist and party-line with the hand: $alternate."
                puthelp "NOTICE $nick :You have been added to the $chan oplist and party-line by $me with the hand: $alternate."
		puthelp "NOTICE $nick :You must set a password type: \002/msg $botnick PASS <your_password>\002"
		if {[botisop $chan] && ![isop $nick $chan]} {
			pushmode $chan +o $nick
		}
		return 0
	}
	if {[matchattr $hand -|+o $chan]} {
                puthelp "NOTICE $me :$nick is already an op in $chan with this hand: $hand"
	} {
		chattr $hand -|+o $chan
                puthelp "NOTICE $me :$nick added to the $chan oplist with this hand: $hand."
                puthelp "NOTICE $nick :You have been added to the $chan oplist by $me."
	}
	if {[botisop $chan] && ![isop $nick $chan]} {
		pushmode $chan +o $nick
		return 0
	}
	return 0
}