public void GroupPermissions(ISender sender, ArgumentList args) { var addPerms = args.TryPop("addperms"); var denyPerms = args.TryPop("denyperms"); var removePerms = args.TryPop("removeperms"); var removeDeniedPerms = args.TryPop("removedenied"); var save = args.TryPop("-save"); if (addPerms || denyPerms || removePerms || removeDeniedPerms) { string group, permission; if (args.TryParseTwo <String, String>(out group, out permission)) { if (!XmlParser.HasGroup(group)) { throw new CommandError("{1} `{0}`", group, Languages.NoGroup); } var permissions = permission.Split(','); var add = addPerms || denyPerms; int added = 0, failed = 0; foreach (var node in permissions) { var res = false; if (add) { if (addPerms) { res = XmlParser.AddNodeToGroup(group, node); } else { res = XmlParser.AddDeniedNodeToGroup(group, node); } } else { if (removePerms) { res = XmlParser.RemovePermissionFromGroup(group, node); } else { res = XmlParser.RemoveDeniedPermissionFromGroup(group, node); } } if (res) { added++; } else { failed++; } } if (save) { XmlParser.Save(); } sender.sendMessage( String.Format("{2} {0} {3} {1} {4}", added, failed, add ? Languages.Added : Languages.Removed, Languages.NodesWhere, Languages.Failed ) ); } else { throw new CommandError(Languages.GrpAndNodeExpected); } } else { throw new CommandError(Languages.ArgumentsExpected); } }