public CommandDesc getDesc() {
return Desc;
}
public void handle_command(Service who, String user, String replyto, String arguments) {
SrvAuth temp = ((SrvAuth) who);
String args[] = arguments.split(" ");
String tU = args[0].toLowerCase();
if (args.length == 1) {
if (util.sanitize(tU)) {
if (temp.getUsers().containsKey(tU)) {
if ((temp.getUsers().get(Generic.Users.get(user).authhandle)).getAccess().ordinal() > (temp.getUsers().get(tU).getAccess().ordinal())) // we can only delete people lower than us
{
for (String e : temp.getUsers().get(tU).WhereAccess.keySet()) {
if (((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().get(tU) == SrvChannel_channel.ChanAccess.C_OWNER) { // we have a problem, this person owns the channel
boolean promoted = false;
int threshold = SrvChannel_channel.ChanAccess.C_OWNER.ordinal();
while (!promoted) {
threshold--;
if (threshold < SrvChannel_channel.ChanAccess.C_PEON.ordinal()) { // no suitable replacement found.
// remove channel
((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().remove(e); // drop the channel
Generic.srvPart(who, e, "Channel Unregistered (owner unregistered, no other users).");
Logging.info("SRVCHAN", "Channel " + e + " unregistered by virtue of having no users left.");
promoted = true;
break;
}
for (Map.Entry<String, SrvChannel_channel.ChanAccess> z : (((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().entrySet())) {
// iterate looking for replacement
if (z.getValue().ordinal() >= threshold) {
((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().remove(Generic.Users.get(user).authhandle);
((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().put(Generic.Users.get(user).authhandle, SrvChannel_channel.ChanAccess.C_OWNER);
promoted = true;
break;
}
}
}
}
((SrvChannel) Configuration.getSvc().get(Configuration.chanservice)).getChannels().get(e).getUsers().remove(tU); // remove access from each channel
}
temp.getUsers().remove(tU); // drop the account
Generic.curProtocol.outMODE(who, Generic.Users.get(tU), "-r", "");
// Generic.Users.get(tU).authhandle = null; // user is no longer authed
Generic.curProtocol.outPRVMSG(who, replyto, "User account removed.");
} else
Generic.curProtocol.outPRVMSG(who, replyto, "\u0002Error:\u0002 User has equal/higher access than you!");